membuat template project menggunakan archetype maven

Bolak balik membuat project bolak balik membuat package, class, xml🙂 ,, mending buat satu template project saja

BISMILLAH

q> Senjata yang diguanakan :: eclipse indigo yg sudah terinstall plugin m2eclipse,, maven yang sudah terinstall di OS / sistem operasi.

q> Eclipse > File > New > Other , kemudian ketikkan “maven project”
Selection_034

q> Next
Selection_035

q>Next lg
Selection_036
q>Next maneh
Selection_037

q> Kemudian klik Finish.

Selection_038
q> Liat tree dari project
Selection_039

q> pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.saifiahmada</groupId>
<artifactId>templateproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<zk.version>5.0.6</zk.version>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<packname>-0.0.1-SNAPSHOT-FL-${maven.build.timestamp}</packname>
</properties>
<packaging>war</packaging>
<name>The templateproject Project</name>
<description>The templateproject Project</description>
<licenses>
<license>
<name>GNU LESSER GENERAL PUBLIC LICENSE, Version 3</name>
<url>http://www.gnu.org/licenses/lgpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<repositories>
<repository>
<id>zk repository</id>
<url>http://mavensync.zkoss.org/maven2</url>
</repository>
<repository>
<id>ZK EE Evaluation</id>
<url>http://mavensync.zkoss.org/zk/ee-eval</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>zkmaven</id>
<name>ZK Maven Plugin Repository</name>
<url>http://mavensync.zkoss.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.zkoss.theme</groupId>
<artifactId>breeze</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkmax</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>${zk.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>demo</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>templateproject${packname}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly/demo.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

q> Dalam pom.xml belum ada dependency untuk hibernate dan spring, untuk menambahkan dependency klik kanan project > Maven > Add Dependency

Selection_040
q> Isi Group Id, Artifact Id dan Version seperti pada gambar di atas, kemudian klik OK.

q>Menambahkan dependency spring
Selection_041

q> Kemudian klik OK

q> pom.xml setelah ditambahkan hibernate dan spring

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.saifiahmada</groupId>
<artifactId>templateproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<zk.version>5.0.6</zk.version>
<maven.build.timestamp.format>yyyy-MM-dd</maven.build.timestamp.format>
<packname>-0.0.1-SNAPSHOT-FL-${maven.build.timestamp}</packname>
</properties>
<packaging>war</packaging>
<name>The templateproject Project</name>
<description>The templateproject Project</description>
<licenses>
<license>
<name>GNU LESSER GENERAL PUBLIC LICENSE, Version 3</name>
<url>http://www.gnu.org/licenses/lgpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<repositories>
<repository>
<id>zk repository</id>
<url>http://mavensync.zkoss.org/maven2</url>
</repository>
<repository>
<id>ZK EE Evaluation</id>
<url>http://mavensync.zkoss.org/zk/ee-eval</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>zkmaven</id>
<name>ZK Maven Plugin Repository</name>
<url>http://mavensync.zkoss.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.zkoss.theme</groupId>
<artifactId>breeze</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkmax</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zkplus</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.zkoss.zk</groupId>
<artifactId>zhtml</artifactId>
<version>${zk.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.8.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.4</source>
<target>1.4</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>demo</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>templateproject${packname}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly/demo.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

q> Buat package baru untuk tempat bean class, dao dan daoimpl. Seperti pada gambar di bawah ini ::
Selection_042

q> Saatnya menjadikan project ini sebagai archetype, buka terminal dan masuk ke dalam direktory project
Selection_043

q>command untuk membuat archetype dari project yang sudah ada ( existing project)

mvn archetype:create-from-project

q> Pastikan pada terminal ada keterangan Succesfull, seperti pada gambar di bawah ini ::
Selection_044

q> Command di atas akan membuat folder target pada project,
q> masuk ke folder  target/generated-sources/archetype/
Selection_045

q> Di deriktory ini tempat instal archetype, ketik command di bawah ini

mvn clean install

q> Setelah itu sukses, masuk ke direktory workspace

q>Jalankan command ini untuk membuat project baru

mvn archetype:generate -DarchetypeCatalog=local[/sorucecode]

Selection_046

q> Isi angka 4 dan ikuti seperti gambar di bawah ini ::
– pilih angka 4
– Define value for property ‘groupId’: : com.saifiahmada
-Define value for property ‘artifactId’: : belajarzk
-Define value for property ‘version’: 1.0-SNAPSHOT: 1.0
-Define value for property ‘package’: com.saifiahmada: com.saifiahmada.belajarzk

Selection_047
q> Jika sukses maka terminal terlihat seperti gambar di bawah ini ::
Selection_048

q> Masuk ke dalam folder project yang baru dibuat yaitu instance, dan liat tree nya
Selection_049

q> Kemudia import project baru ini ke dalam eclipse , File > Import >
Selection_050
q> Klik Next dan browse project instance tadi yang berada pada workspace
Selection_051

q> Klik Finish

q>Tenggg tengg project jadi
Selection_052

q> Selesai

ALHAMDULILLAH

Published by

saifiahmada

Begin a big Process with a bit trying

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s