Last active
December 19, 2015 12:28
-
-
Save theotherian/5954600 to your computer and use it in GitHub Desktop.
Maven Archetype how to pieces for the first blog post at http://www.theotherian.com/2012/05/maven-archetypes-part-1-where-do-i.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Files for creating Maven Archetypes - part 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<archetype-catalog> | |
<archetypes> | |
<archetype> | |
<groupId>com.theotherian.archetype</groupId> | |
<artifactId>sample-archetype</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<description>Our Sample Archetype</description> | |
</archetype> | |
</archetypes> | |
</archetype-catalog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<archetype-descriptor name="sample-archetype"> | |
<fileSets> | |
<fileSet filtered="true"> | |
<directory></directory> | |
<includes> | |
<include>pom.xml</include> | |
</includes> | |
</fileSet> | |
</fileSets> | |
</archetype-descriptor> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tree | |
. | |
|____pom.xml | |
|____src | |
| |____main | |
| | |____resources | |
| | | |____archetype-resources | |
| | | | |____pom.xml | |
| | | |____META-INF | |
| | | | |____maven | |
| | | | | |____archetype-metadata.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd sample-archetype | |
$ mkdir -p src/main/resources/archetype-resources | |
$ mkdir -p src/main/resources/META-INF/maven | |
$ touch src/main/resources/META-INF/maven/archetype-metadata.xml | |
$ touch src/main/resources/archetype-resources/pom.xml | |
$ touch pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mvn clean install | |
[INFO] Scanning for projects... | |
[INFO] | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Building sample-project 1.0-SNAPSHOT | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] | |
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ sample-project --- | |
[INFO] | |
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ sample-project --- | |
[INFO] Installing /Users/isimpson/sample-projects/sample-project/pom.xml to /Users/isimpson/.m2/repository/com/theotherian/sample-project/1.0-SNAPSHOT/sample-project-1.0-SNAPSHOT.pom | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] BUILD SUCCESS | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 0.480s | |
[INFO] Finished at: Sat May 12 11:01:18 MDT 2012 | |
[INFO] Final Memory: 3M/81M | |
[INFO] ------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd .. | |
$ mvn archetype:generate -DarchetypeCatalog=local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] Building Maven Default Project | |
[INFO] task-segment: [archetype:generate] (aggregator-style) | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Preparing archetype:generate | |
[INFO] No goals needed for project - skipping | |
[INFO] [archetype:generate {execution: default-cli}] | |
[INFO] Generating project in Interactive mode | |
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) | |
Choose archetype: | |
1: local -> sample-archetype (Our Sample Archetype) | |
Choose a number: : | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Choose a number: : 1 | |
Define value for property 'groupId': : com.theotherian | |
Define value for property 'artifactId': : sample-project | |
Define value for property 'version': 1.0-SNAPSHOT: | |
Define value for property 'package': com.theotherian: | |
Confirm properties configuration: | |
groupId: com.theotherian | |
artifactId: sample-project | |
version: 1.0-SNAPSHOT | |
package: com.theotherian | |
Y: | |
[WARNING] Don't override file /Users/isimpson/sample-projects/sample-project/pom.xml | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] BUILD SUCCESSFUL | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 34 seconds | |
[INFO] Finished at: Sun May 23 19:48:56 MDT 2010 | |
[INFO] Final Memory: 16M/80M | |
[INFO] ------------------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
<name>sample-archetype</name> | |
<groupId>com.theotherian.archetype</groupId> | |
<artifactId>sample-archetype</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>maven-archetype</packaging> | |
<build> | |
<extensions> | |
<extension> | |
<groupId>org.apache.maven.archetype</groupId> | |
<artifactId>archetype-packaging</artifactId> | |
<version>2.1</version> | |
</extension> | |
</extensions> | |
<pluginManagement> | |
<plugins> | |
<plugin> | |
<artifactId>maven-archetype-plugin</artifactId> | |
<version>2.1</version> | |
<extensions>true</extensions> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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>${groupId}</groupId> | |
<artifactId>${artifactId}</artifactId> | |
<version>${version}</version> | |
<packaging>pom</packaging> | |
<name>${artifactId}</name> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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.theotherian</groupId> | |
<artifactId>sample-project</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>pom</packaging> | |
<name>sample-project</name> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd sample-project/ | |
$ mvn clean install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment