1 package org.mule.tools.maven.archetype;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.apache.maven.archetype.Archetype;
24 import org.apache.maven.archetype.ArchetypeDescriptorException;
25 import org.apache.maven.archetype.ArchetypeNotFoundException;
26 import org.apache.maven.archetype.ArchetypeTemplateProcessingException;
27 import org.apache.maven.artifact.repository.ArtifactRepository;
28 import org.apache.maven.plugin.AbstractMojo;
29 import org.apache.maven.plugin.MojoExecutionException;
30
31
32
33
34
35
36
37
38
39
40 public class TransportArchetypeMojo extends AbstractMojo
41 {
42
43
44
45
46 private Archetype archetype;
47
48
49
50
51
52 private ArtifactRepository localRepository;
53
54
55
56
57
58 private String archetypeGroupId;
59
60
61
62
63
64 private String archetypeArtifactId;
65
66
67
68
69
70 private String archetypeVersion;
71
72
73
74
75
76 private String muleVersion;
77
78
79
80
81
82 private String transportId;
83
84
85
86
87
88 private String groupId;
89
90
91
92
93
94 private String artifactId;
95
96
97
98
99
100 private String version;
101
102
103 private String packageName;
104
105
106
107
108
109 private List remoteRepositories;
110
111 public void execute()
112 throws MojoExecutionException
113 {
114
115
116
117
118
119
120
121
122
123
124
125 String basedir = System.getProperty("user.dir");
126
127 if (packageName == null)
128 {
129 getLog().info("Defaulting package to group ID: " + groupId);
130
131 packageName = groupId;
132 }
133
134
135 Map map = new HashMap();
136
137 map.put("basedir", basedir);
138
139 map.put("package", packageName);
140
141 map.put("packageName", packageName);
142
143 map.put("groupId", groupId);
144
145 map.put("artifactId", artifactId);
146
147 map.put("version", version);
148 map.put("muleVersion", muleVersion);
149 map.put("transportId", transportId);
150
151
152 try
153 {
154 archetype.createArchetype(archetypeGroupId, archetypeArtifactId, archetypeVersion, localRepository, remoteRepositories, map);
155 }
156 catch (ArchetypeNotFoundException e)
157 {
158 throw new MojoExecutionException("Error creating from archetype", e);
159 }
160 catch (ArchetypeDescriptorException e)
161 {
162 throw new MojoExecutionException("Error creating from archetype", e);
163 }
164 catch (ArchetypeTemplateProcessingException e)
165 {
166 throw new MojoExecutionException("Error creating from archetype", e);
167 }
168 }
169
170
171 }