diff --git a/maven/bnd-baseline-maven-plugin/pom.xml b/maven/bnd-baseline-maven-plugin/pom.xml index 5f24f09c18..53668747d4 100644 --- a/maven/bnd-baseline-maven-plugin/pom.xml +++ b/maven/bnd-baseline-maven-plugin/pom.xml @@ -11,8 +11,8 @@ bnd-baseline-maven-plugin - This maven plugin is used to baseline OSGi bundles. - ${project.groupId}:${project.artifactId} + The bnd baseline maven plugin is used to baseline OSGi bundles. + Bnd Baseline Maven Plugin maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-export-maven-plugin/pom.xml b/maven/bnd-export-maven-plugin/pom.xml index 5f854c09d2..9822756ec6 100644 --- a/maven/bnd-export-maven-plugin/pom.xml +++ b/maven/bnd-export-maven-plugin/pom.xml @@ -9,8 +9,8 @@ ../bnd-plugin-parent bnd-export-maven-plugin - Resolve and Export OSGi applications. - ${project.groupId}:${project.artifactId} + The bnd export maven plugin can be used to export OSGi applications. + Bnd Export Maven Plugin maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-indexer-maven-plugin/pom.xml b/maven/bnd-indexer-maven-plugin/pom.xml index b607306ef5..3165de07cf 100644 --- a/maven/bnd-indexer-maven-plugin/pom.xml +++ b/maven/bnd-indexer-maven-plugin/pom.xml @@ -11,8 +11,8 @@ bnd-indexer-maven-plugin - This maven plugin is used to make OSGi indexes from lists of maven dependencies. - ${project.groupId}:${project.artifactId} + The bnd indexer maven plugin is used to make OSGi indexes from lists of maven dependencies. + Bnd Indexer Maven Plugin maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-maven-plugin/pom.xml b/maven/bnd-maven-plugin/pom.xml index eb50097574..314c438888 100644 --- a/maven/bnd-maven-plugin/pom.xml +++ b/maven/bnd-maven-plugin/pom.xml @@ -11,8 +11,8 @@ bnd-maven-plugin - This maven plugin is used to build OSGi bundles using the bnd tool for generating MANIFEST.MF and other OSGi-specific artifacts. - ${project.groupId}:${project.artifactId} + The bnd maven plugin is used to build OSGi bundles using bnd for generating MANIFEST.MF and other OSGi-specific artifacts. + Bnd Maven Plugin maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java index f5982e0966..54e61e929d 100644 --- a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java +++ b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java @@ -40,6 +40,8 @@ import java.util.zip.ZipFile; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.ArtifactHandler; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.model.Developer; import org.apache.maven.model.License; @@ -80,6 +82,9 @@ import aQute.lib.utf8properties.UTF8Properties; import aQute.service.reporter.Report.Location; +/** + * Abstract base class for all bnd-maven-plugin mojos. + */ public abstract class AbstractBndMavenPlugin extends AbstractMojo { protected final Logger logger = LoggerFactory.getLogger(getClass()); static final String MANIFEST_LAST_MODIFIED = "aQute.bnd.maven.plugin.BndMavenPlugin.manifestLastModified"; @@ -90,11 +95,18 @@ public abstract class AbstractBndMavenPlugin extends AbstractMojo { static final String SNAPSHOT = "SNAPSHOT"; @Parameter(defaultValue = "${project.build.directory}", readonly = true) - File targetDir; + File buildDir; + /** + * Whether to include the contents of the {@code classesDir} directory + * in the generated bundle. + */ @Parameter(defaultValue = "true") boolean includeClassesDir; + /** + * The directory where this plugin will store its output when packaging is {@code war}. + */ @Parameter(defaultValue = "${project.build.directory}/${project.build.finalName}") File warOutputDir; @@ -107,14 +119,27 @@ public abstract class AbstractBndMavenPlugin extends AbstractMojo { @Parameter(defaultValue = "${mojoExecution}", readonly = true) MojoExecution mojoExecution; + /** + * The list of maven packaging types for which the plugin will execute. + */ @Parameter(property = "bnd.packagingTypes", defaultValue = PACKAGING_JAR + "," + PACKAGING_WAR) List packagingTypes; + /** + * Skip processing if {@link #includeClassesDir} is {@code true} and the + * {@code classesDir} directory is empty. + */ @Parameter(property = "bnd.skipIfEmpty", defaultValue = "false") boolean skipIfEmpty; + /** + * If set, the generated output will be reproducible. + * + * @see Configuring + * for Reproducible Builds + */ @Parameter(defaultValue = "${project.build.outputTimestamp}") - private String outputTimestamp; + String outputTimestamp; /** * File path to a bnd file containing bnd instructions for this project. @@ -149,6 +174,9 @@ public abstract class AbstractBndMavenPlugin extends AbstractMojo { @Component MavenProjectHelper projectHelper; + @Component + private ArtifactHandlerManager artifactHandlerManager; + File propertiesFile; public abstract File getSourceDir(); @@ -208,7 +236,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { builder.setBase(project.getBasedir()); propertiesFile = loadProperties(builder); - builder.setProperty("project.output", targetDir.getCanonicalPath()); + builder.setProperty("project.output", buildDir.getCanonicalPath()); // If no bundle to be built, we have nothing to do if (Processor.isTrue(builder.getProperty(Constants.NOBUNDLES))) { @@ -225,12 +253,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { // always add the outputDirectory to the classpath, but // handle projects with no output directory, like // 'test-wrapper-bundle' - if (getClassesDir().isDirectory()) { - builder.addClasspath(getClassesDir()); + if (classesDir.isDirectory()) { + builder.addClasspath(classesDir); Jar classesDirJar; if (includeClassesDir) { - classesDirJar = new Jar(project.getName(), getClassesDir()); + classesDirJar = new Jar(project.getName(), classesDir); } else { classesDirJar = new Jar(project.getName()); // empty jar } @@ -574,10 +602,10 @@ private static StringBuilder addHeaderAttribute(StringBuilder builder, String ke private void attachArtifactToProject(Jar bndJar) throws Exception { File artifactFile = createArtifactFile(); - File outputDir = artifactFile.getParentFile(); + File parent = artifactFile.getParentFile(); - if (!outputDir.exists()) { - IO.mkdirs(outputDir); + if (!parent.exists()) { + IO.mkdirs(parent); } try (OutputStream os = buildContext.newFileOutputStream(artifactFile)) { @@ -621,11 +649,19 @@ private void addMavenMetadataToJar(Jar bndJar) throws IOException { } private File createArtifactFile() { - return new File(targetDir, project.getBuild() + return new File(buildDir, project.getBuild() .getFinalName() + getClassifier().map("-"::concat) .orElse("") - + "." + project.getPackaging()); + + "." + getExtension(project.getPackaging())); + } + + private String getExtension(String type) { + ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(type); + if (artifactHandler != null) { + type = artifactHandler.getExtension(); + } + return type; } private String createArtifactName(Artifact artifact) { diff --git a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingPlugin.java b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingPlugin.java index 93847f4676..0f192ea5d1 100644 --- a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingPlugin.java +++ b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingPlugin.java @@ -7,9 +7,18 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +/** + * Generate OSGi metadata for the target classes and + * package into a jar. + *

+ * This goal has the default phase of "package". + */ @Mojo(name = "jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) public class BndMavenPackagingPlugin extends BndMavenPlugin { + /** + * The classifier to use for the generated artifact. + */ @Parameter private String classifier; diff --git a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingTestsPlugin.java b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingTestsPlugin.java index 5006a1a68f..a4a65c39a6 100644 --- a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingTestsPlugin.java +++ b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPackagingTestsPlugin.java @@ -7,9 +7,18 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +/** + * Generate OSGi metadata for the test target classes and + * package into a jar. + *

+ * This goal has the default phase of "package". + */ @Mojo(name = "test-jar", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class BndMavenPackagingTestsPlugin extends BndMavenTestsPlugin { + /** + * The classifier to use for the generated artifact. + */ @Parameter(defaultValue = "tests") private String classifier; diff --git a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPlugin.java b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPlugin.java index c57dd155fd..c75ad18859 100644 --- a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPlugin.java +++ b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenPlugin.java @@ -9,6 +9,11 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +/** + * Processes the target classes to generate OSGi metadata. + *

+ * This goal has the default phase of "process-classes". + */ @Mojo(name = "bnd-process", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE, threadSafe = true) public class BndMavenPlugin extends AbstractBndMavenPlugin { @@ -18,15 +23,27 @@ public class BndMavenPlugin extends AbstractBndMavenPlugin { @Parameter(defaultValue = "${project.build.resources}", readonly = true) private List resources; + /** + * The directory where the {@code maven-compiler-plugin} places its output. + */ @Parameter(defaultValue = "${project.build.outputDirectory}") private File classesDir; + /** + * The directory where this plugin will store its output. + */ @Parameter(defaultValue = "${project.build.outputDirectory}") private File outputDir; + /** + * Specify the path to store the generated manifest file. + */ @Parameter(defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF") File manifestPath; + /** + * Skip this goal. + */ @Parameter(property = "bnd.skip", defaultValue = "false") boolean skip; diff --git a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenTestsPlugin.java b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenTestsPlugin.java index b830d77031..f8f6b47f7b 100644 --- a/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenTestsPlugin.java +++ b/maven/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/BndMavenTestsPlugin.java @@ -29,10 +29,17 @@ import aQute.bnd.osgi.Builder; import aQute.bnd.osgi.Constants; +/** + * Processes the test target classes to generate OSGi metadata. + *

+ * This goal has the default phase of "process-test-classes". + */ @Mojo(name = "bnd-process-tests", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true) public class BndMavenTestsPlugin extends AbstractBndMavenPlugin { /** + * Whether the test artifact is an OSGi fragment. + *

* If true, make the tests artifact a fragment using * ${project.artifactId} as the {@code Fragment-Host} * header and setting the {@code Bundle-SymbolicName} of the tests artifact @@ -42,6 +49,9 @@ public class BndMavenTestsPlugin extends AbstractBndMavenPlugin { private boolean artifactFragment; /** + * The test case types to generate into the {@code Test-Cases} + * manifest header. + *

* Possible values are {@link TestCases#junit3 junit3}, * {@link TestCases#junit4 junit4}, {@link TestCases#junit5 junit5}, * {@link TestCases#all all}, {@link TestCases#testng testng}, and @@ -56,21 +66,41 @@ public class BndMavenTestsPlugin extends AbstractBndMavenPlugin { @Parameter(defaultValue = "${project.build.testResources}", readonly = true) private List resources; - @Parameter(defaultValue = "${project.build.outputDirectory}", readonly = true, required = false) + /** + * The directory where the {@code maven-compiler-plugin} placed the main output. + */ + @Parameter(defaultValue = "${project.build.outputDirectory}") private File mainClassesDir; - @Parameter(defaultValue = "${project.build.testOutputDirectory}", readonly = true) + /** + * The directory where the {@code maven-compiler-plugin} places its output. + */ + @Parameter(defaultValue = "${project.build.testOutputDirectory}") private File classesDir; - @Parameter(defaultValue = "${project.build.testOutputDirectory}", readonly = true) + /** + * The directory where this plugin will store its output. + */ + @Parameter(defaultValue = "${project.build.testOutputDirectory}") private File outputDir; - @Parameter(defaultValue = "${project.build.testOutputDirectory}/META-INF/MANIFEST.MF", readonly = true) + /** + * Specify the path to store the generated manifest file. + */ + @Parameter(defaultValue = "${project.build.testOutputDirectory}/META-INF/MANIFEST.MF") private File manifestPath; + /** + * Skip this goal. The goal can also be skipped with the {@link #skipGoal} + * configuration. + */ @Parameter(property = "maven.test.skip", defaultValue = "false") private boolean skip; + /** + * Skip this goal. The goal can also be skipped with the {@link #skip} + * configuration. + */ @Parameter(property = "bnd-tests.skip", defaultValue = "false") private boolean skipGoal; diff --git a/maven/bnd-reporter-maven-plugin/pom.xml b/maven/bnd-reporter-maven-plugin/pom.xml index 83f28563ee..a043b1dfd3 100644 --- a/maven/bnd-reporter-maven-plugin/pom.xml +++ b/maven/bnd-reporter-maven-plugin/pom.xml @@ -9,8 +9,8 @@ ../bnd-plugin-parent bnd-reporter-maven-plugin - Generates and exports reports of projects - ${project.groupId}:${project.artifactId} + The bnd reporter maven plugin generates and exports reports of projects. + Bnd Reporter Maven Plugin maven-plugin http://bnd.bndtools.org/ diff --git a/maven/bnd-resolver-maven-plugin/pom.xml b/maven/bnd-resolver-maven-plugin/pom.xml index d3309831cb..6b955df5ac 100644 --- a/maven/bnd-resolver-maven-plugin/pom.xml +++ b/maven/bnd-resolver-maven-plugin/pom.xml @@ -9,8 +9,8 @@ ../bnd-plugin-parent bnd-resolver-maven-plugin - Resolves the -runbundles for an OSGi bndrun file - ${project.groupId}:${project.artifactId} + The bnd resolver maven plugin resolves the -runbundles for a bndrun file. + Bnd Resolver Maven Plugins maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-run-maven-plugin/pom.xml b/maven/bnd-run-maven-plugin/pom.xml index 0ce3f6f20a..a196044b26 100644 --- a/maven/bnd-run-maven-plugin/pom.xml +++ b/maven/bnd-run-maven-plugin/pom.xml @@ -9,8 +9,8 @@ ../bnd-plugin-parent bnd-run-maven-plugin - Run an OSGi bndrun file - ${project.groupId}:${project.artifactId} + The bnd run maven plugin is used to run a bndrun file. + Bnd Run Maven Plugin maven-plugin https://bnd.bndtools.org/ diff --git a/maven/bnd-testing-maven-plugin/pom.xml b/maven/bnd-testing-maven-plugin/pom.xml index 2e414c2ad3..118f302d56 100644 --- a/maven/bnd-testing-maven-plugin/pom.xml +++ b/maven/bnd-testing-maven-plugin/pom.xml @@ -9,8 +9,8 @@ ../bnd-plugin-parent bnd-testing-maven-plugin - Run the tests from an OSGi bndrun file - ${project.groupId}:${project.artifactId} + The bnd testing maven plugin is used to run the tests from a bndrun file. + Bnd Testing Maven Plugin maven-plugin https://bnd.bndtools.org/