/
pom.xml
394 lines (374 loc) · 19.5 KB
/
pom.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<?xml version="1.0" encoding="UTF-8"?>
<!-- vi: set et smarttab sw=4 tabstop=4: -->
<!--
Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
<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">
<!--
Base parent pom for building, packaging and testing Karaf features.
Users should do the following:
- specify this as their parent
- define their features template in src/main/features
- make sure the packaging is set to jar
- setup projects <dependencies/> as needed for their features
-->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
<version>1.9.1-SNAPSHOT</version>
<relativePath>../odlparent</relativePath>
</parent>
<artifactId>features-parent</artifactId>
<packaging>pom</packaging>
<name>ODL :: odlparent :: ${project.artifactId}</name>
<properties>
<features.file>features.xml</features.file>
<skip.karaf.featureTest>false</skip.karaf.featureTest>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<pluginManagement>
<plugins>
<!-- generate dependencies versions -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals><goal>resolve</goal></goals>
<configuration>
<outputFile>${project.build.directory}/dependencies.txt</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.alexecollins.maven.plugin</groupId>
<artifactId>script-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>add-version-to-features</id>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<language>groovy</language>
<script>
/**
* Placeholder, which is used in src/features/features.xml
* to mark version which should be inserted from dependencies.
* Currently works only for bundle and configfile tags
* with mvn: url schema, and needs to be used
* as third component of schema.
* eg. mvn:group/artefact/{{VERSION}}
*/
def versionPlaceholder = "{{VERSION}}"
/**
* Path to features.xml which uses versionPlaceholder.
* This will be processed by this script.
*
*/
def featureFilePath = "src/main/features/features.xml"
// Contains mapping of groupID:artefactID to versoin
def versionMap = new HashMap();
/* Loads transitive dependency list generated from
* maven-dependency-plugin resolve goal
* and populates map
*/
def dependencies = new File(project.build.directory,"dependencies.txt")
dependencies.eachLine {
def cmps = it.trim().split(":")
// Depends on number of components:
// - groupId
// - artifactId
// - Type
// - Qualifier (optional)
// - Version
// - Scope
if(cmps.length > 4) {
def id = cmps[0] + ":" + cmps[1]
if(cmps.length == 6) {
versionMap[id] = cmps[4]
} else if(cmps.length == 5) {
versionMap[id] = cmps[3]
}
}
}
/*
* Takes splitted mvn: URL, looks for placeholder
* and returns new mvn: URL with version learned
* from dependency plugin.
*
* If referenced bundle is not dependency (direct or transitive)
* throws an exception and fails build.
*
*/
def updatedURLFromProject = { args ->
// 0 - groupID, 1 - artifactID
// 2 - version, 3 - type, 4 - Classifier
def groupId = args[0];
def artifactId = args[1];
def id = groupId + ":" + artifactId
def dependencyVersion = versionMap[id]
if(dependencyVersion != null) {
// Overriding version
args[2] = dependencyVersion
return "mvn:" + args.join("/")
}
throw new IllegalArgumentException("Feature dependency $groupId:$artifactId is not a dependency in the project pom.xml.")
}
def updateMavenDependency = { dep ->
def mvnUrl = dep.text()
def prefix = ""
if (mvnUrl.startsWith("wrap:")) {
prefix = "wrap:"
mvnUrl = mvnUrl.substring(5)
}
if (mvnUrl.startsWith("mvn:") && mvnUrl.indexOf(versionPlaceholder) >= 0) {
// Process property place-holders
def dollarIndex;
while ((dollarIndex = mvnUrl.indexOf("\${")) >= 0) {
def closingBrace = mvnUrl.indexOf("}", dollarIndex);
if (closingBrace > dollarIndex) {
def propKey = mvnUrl.substring(dollarIndex + 2, closingBrace);
def propVal = project.properties[propKey];
mvnUrl = mvnUrl.replace("\${${propKey}}", propVal);
} else {
println "[WARN] Malformed Maven URL: ${mvnUrl}";
break;
}
}
def components = mvnUrl.substring(4).split("/")
if (components[2].startsWith(versionPlaceholder)) {
def suffix = "";
if (components[2].length() > versionPlaceholder.length()) {
suffix = components[2].substring(versionPlaceholder.length())
components[2] = versionPlaceholder
}
dep.value = prefix + updatedURLFromProject(components) + suffix
}
}
}
def featureFile = new File(project.basedir,featureFilePath)
def root = new XmlParser().parse(featureFile)
println "[INFO] Updating repository declarations"
root.repository.each updateMavenDependency
root.feature.each { feature ->
println "[INFO] Processing feature: ${feature.@name}"
feature.bundle.each updateMavenDependency
feature.configfile.each updateMavenDependency
}
def outDir = new File(project.build.directory,"generated-resources/script")
outDir.mkdirs();
def outFile = new File(outDir,"features.xml")
def outWriter = outFile.newPrintWriter("ASCII");
xmlPrinter = new XmlNodePrinter(outWriter);
xmlPrinter.preserveWhitespace = true
xmlPrinter.print(root)
outWriter.close();
</script>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.8.6</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>features-create-kar</id>
<goals>
<goal>features-create-kar</goal>
</goals>
<configuration>
<featuresFile>${project.build.directory}/classes/${features.file}</featuresFile>
</configuration>
</execution>
</executions>
<!-- There is no useful configuration for the kar mojo. The features-generate-descriptor mojo configuration may be useful -->
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals><goal>add-resource</goal></goals>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}/generated-resources/script</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/classes/${features.file}</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>filter</id>
<phase>generate-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<skip>${skip.karaf.featureTest}</skip>
<systemPropertyVariables>
<!-- Remove these properties when a better fix to Bug 6523 appears. -->
<karaf.distro.groupId>org.opendaylight.odlparent</karaf.distro.groupId>
<karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
<karaf.distro.version>1.9.1-SNAPSHOT</karaf.distro.version>
</systemPropertyVariables>
<dependenciesToScan>
<dependency>org.opendaylight.odlparent:features-test</dependency>
</dependenciesToScan>
</configuration>
</plugin>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.alexecollins.maven.plugin</groupId>
<artifactId>script-maven-plugin</artifactId>
<versionRange>[0.0,)</versionRange>
<goals>
<goal>execute</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[0.0,)</versionRange>
<goals>
<goal>resolve</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!-- This generates the META-INF/maven/dependencies.properties file
which is required by the versionAsInProject() used in SingleFeatureTest -->
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.alexecollins.maven.plugin</groupId>
<artifactId>script-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<!-- test the features.xml -->
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>features-test</artifactId>
<version>1.9.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- Remove this dependency when a better fix for Bug 6523 appears. -->
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>opendaylight-karaf-empty</artifactId>
<version>1.9.1-SNAPSHOT</version>
<type>zip</type>
<scope>test</scope>
</dependency>
</dependencies>
<!--
Maven Site Configuration
The following configuration is necessary for maven-site-plugin to
correctly identify the correct deployment path for OpenDaylight Maven
sites.
-->
<url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
<distributionManagement>
<site>
<id>opendaylight-site</id>
<url>${nexus.site.url}/${project.artifactId}/</url>
</site>
</distributionManagement>
</project>