关于Maven原型工程的制作就不在这里详细介绍了,具体细节请参考之前的文章: 定制Maven原型生成项目
1
2
|
org.apache.maven.archetype.exception.ArchetypeGenerationFailure:
Error merging velocity templates: Unable to find resource 'archetype-resources/__rootArtifactId__-aggregator/../__rootArtifactId__-common/pom.xml'
|
1
2
3
|
< modules >
< module >xyz-aggregator</ module >
</ modules >
|
1
2
3
4
|
< modules >
< module >../xyz-common</ module >
< module >../xyz-web</ module >
</ modules >
|
└── generated-sources
└── archetype
├── pom.xml
└── src
└── main
└── resources
├── archetype-resources
│ ├── __rootArtifactId__-aggregator
│ │ └── pom.xml
│ ├── __rootArtifactId__-common
│ │ ├── pom.xml
│ │ └── src
│ ├── __rootArtifactId__-web
│ │ ├── pom.xml
│ │ └── src
│ ├── pom.xml
│ └── quick-start.bat
└── META-INF
└── maven
├── archetype.xml
└── archetype-metadata.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<? xml version = "1.0" encoding = "UTF-8" ?>< archetype-descriptor name = "basic" >
< fileSets >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory ></ directory >
< includes >
< include >README.txt</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory ></ directory >
< includes >
< include >quick-start.bat</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" packaged = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-common/src/main/java</ directory >
< includes >
< include >**/*.java</ include >
</ includes >
</ fileSet >
< fileSet packaged = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-common/src/main/java</ directory >
< includes >
< include >**/*.wsdl</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-common/src/main/resources</ directory >
< includes >
< include >**/*.xml</ include >
</ includes >
</ fileSet >
< fileSet encoding = "UTF-8" >
< directory >__rootArtifactId__-common/src/META-INF</ directory >
< includes >
< include >**/*.MF</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-common</ directory >
< includes >
< include >pom.xml</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" packaged = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-web/src/main/java</ directory >
< includes >
< include >**/*.java</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-web/src/main/webapp</ directory >
< includes >
< include >**/*.vm</ include >
< include >**/*.xml</ include >
< include >**/*.txt</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-web/src/main/resources</ directory >
< includes >
< include >**/*.xml</ include >
< include >**/*.properties</ include >
</ includes >
</ fileSet >
< fileSet encoding = "UTF-8" >
< directory >__rootArtifactId__-web/src/main/webapp</ directory >
< includes >
< include >**/*.jpg</ include >
< include >**/*.db</ include >
< include >**/*.MF</ include >
< include >**/*.png</ include >
< include >**/*.js</ include >
< include >**/*.htm</ include >
< include >**/*.gif</ include >
< include >**/*.css</ include >
</ includes >
</ fileSet >
< fileSet filtered = "true" encoding = "UTF-8" >
< directory >__rootArtifactId__-web</ directory >
< includes >
< include >pom.xml</ include >
</ includes >
</ fileSet >
</ fileSets >
< modules >
< module id = "${rootArtifactId}-aggregator" dir = "__rootArtifactId__-aggregator" name = "${rootArtifactId}-aggregator" >
< fileSets >
</ fileSets >
</ module >
</ modules >
</ archetype-descriptor >
|
1
2
3
|
< fileSet filtered = "true" packaged = "false" encoding = "UTF-8" >
< directory >__rootArtifactId__-web/src/main/java/__packageInPathFormat__/foo</ directory >
</ fileSet >
|
1
2
3
4
5
6
7
|
< servers >
< server >
< id >my-snapshot</ id >
< username >admin</ username >
< password >admin123</ password >
</ server >
</ servers >
|
1
2
3
4
|
mvn deploy:deploy-file \
-DgroupId=com.xyz -DartifactId=xyz-archetype -Dversion=1.0-SNAPSHOT \
-Dpackaging=maven-archetype -Dfile=xyz-archetype-1.0-SNAPSHOT.jar \
-DrepositoryId=my-snapshot -Durl=http://127.0.0.1:8989/nexus/content/repositories/snapshots/
|
1
2
3
4
5
6
|
< repository >
< snapshots />
< id >my-snapshot</ id >
< name >my-snapshot</ name >
< url >http://127.0.0.1:8989/nexus/content/repositories/snapshots/</ url >
</ repository >
|
1
2
3
4
|
mvn archetype:generate -B \
-DarchetypeCatalog=remote -DarchetypeRepository=my-snapshot \
-DarchetypeGroupId=com.xyz -DarchetypeArtifactId=xyz-archetype -DarchetypeVersion=1.0-SNAPSHOT \
-DgroupId=com.abc -DartifactId=abc
|