19
19
* under the License.
20
20
*/
21
21
22
+ import static org .apache .aries .util .manifest .BundleManifest .fromBundle ;
23
+
22
24
import java .io .File ;
23
25
import java .io .IOException ;
24
26
import java .util .HashSet ;
28
30
import java .util .Map ;
29
31
import java .util .Set ;
30
32
33
+ import org .apache .aries .util .manifest .BundleManifest ;
31
34
import org .apache .maven .archiver .PomPropertiesUtil ;
32
35
import org .apache .maven .artifact .Artifact ;
33
36
import org .apache .maven .plugin .AbstractMojo ;
@@ -239,7 +242,9 @@ private void addDependenciesToArchive() throws MojoExecutionException {
239
242
artifacts .add (project .getArtifact ());
240
243
}
241
244
242
- artifacts = selectArtifacts (artifacts );
245
+ artifacts = selectArtifactsInCompileOrRuntimeScope (artifacts );
246
+ artifacts = selectNonJarArtifactsAndBundles (artifacts );
247
+
243
248
int cnt = 0 ;
244
249
for (Artifact artifact : artifacts ) {
245
250
if (!artifact .isOptional () /*&& filter.include(artifact)*/ ) {
@@ -424,9 +429,8 @@ private void writeSubsystemManifest(String fileName)
424
429
}
425
430
426
431
// Write the SUBSYSTEM-CONTENT
427
- // TODO: check that the dependencies are bundles (currently, the converter
428
- // will throw an exception)
429
432
Set <Artifact > artifacts = null ;
433
+
430
434
switch (EsaManifestContent .valueOf (manifestContent )) {
431
435
case content :
432
436
// only include the direct dependencies in the content
@@ -439,8 +443,10 @@ private void writeSubsystemManifest(String fileName)
439
443
default :
440
444
throw new MojoExecutionException ("Invalid configuration for <manifestContent/>. Valid values are content and all." );
441
445
}
442
-
443
- artifacts = selectArtifacts (artifacts );
446
+
447
+ artifacts = selectArtifactsInCompileOrRuntimeScope (artifacts );
448
+ artifacts = selectNonJarArtifactsAndBundles (artifacts );
449
+
444
450
Iterator <Artifact > iter = artifacts .iterator ();
445
451
446
452
FileUtils .fileAppend (fileName , Constants .SUBSYSTEM_CONTENT + ": " );
@@ -551,7 +557,7 @@ private void includeCustomSubsystemManifestFile()
551
557
/**
552
558
* Return non-pom artifacts in 'compile' or 'runtime' scope only.
553
559
*/
554
- private Set <Artifact > selectArtifacts (Set <Artifact > artifacts )
560
+ private Set <Artifact > selectArtifactsInCompileOrRuntimeScope (Set <Artifact > artifacts )
555
561
{
556
562
Set <Artifact > selected = new LinkedHashSet <Artifact >();
557
563
for (Artifact artifact : artifacts ) {
@@ -567,6 +573,31 @@ private Set<Artifact> selectArtifacts(Set<Artifact> artifacts)
567
573
return selected ;
568
574
}
569
575
576
+ /**
577
+ * Returns bundles and artifacts that aren't JARs
578
+ */
579
+ private Set <Artifact > selectNonJarArtifactsAndBundles (Set <Artifact > artifacts )
580
+ {
581
+ Set <Artifact > selected = new LinkedHashSet <Artifact >();
582
+ for (Artifact artifact : artifacts ) {
583
+ if (isNonJarOrOSGiBundle (artifact )) {
584
+ selected .add (artifact );
585
+ } else {
586
+ getLog ().warn ("Skipping dependency on non-bundle JAR! groupId: " + artifact .getGroupId () + " artifactId:" + artifact .getArtifactId ());
587
+ }
588
+ }
589
+ return selected ;
590
+ }
591
+
592
+ private boolean isNonJarOrOSGiBundle (Artifact artifact ) {
593
+ if (!artifact .getFile ().getName ().endsWith (".jar" )){
594
+ return true ;
595
+ } else {
596
+ BundleManifest manifest = fromBundle (artifact .getFile ());
597
+ return manifest != null && manifest .getSymbolicName () != null ;
598
+ }
599
+ }
600
+
570
601
private void includeSharedResources () throws MojoExecutionException {
571
602
try
572
603
{
0 commit comments