Skip to content

Commit

Permalink
Allow to configure base via coordinates (and CLI argument)
Browse files Browse the repository at this point in the history
This closes bndtools#5721

Signed-off-by: Konrad Windszus <kwin@apache.org>
  • Loading branch information
kwin committed Jul 18, 2023
1 parent 30ea956 commit fa8858e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
12 changes: 11 additions & 1 deletion maven-plugins/bnd-baseline-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,23 @@ version artifact which matches these rules will be used as the baseline.
By default the `bnd-baseline-maven-plugin` will use information from the
current project to set its search parameters, however sometimes an artifact
will move or change name over time, or a particular version should be
targeted. In this case the search parameters can be overridden. If a
targeted. In this case the search parameters can be overridden through {@code baseCoordinates} (since version 7.0.0)
or {@code base} (the former taking precedence). If a
search parameter is omitted then it will take its default value:

<configuration>
<baseCoordinates>${a.different.groupId}:${a.different.artifactId}:${single.version.or.version.range}</baseCoordinates>
</configuration>

or

<configuration>
<base>
<groupId>${a.different.groupId}</groupId>
<artifactId>${a.different.artifactId}</artifactId>
<version>${single.version.or.version.range}</version>
<classifier>${an.optional.classifier}</version>
<extension>${an.optional.extension}</extension>
</base>
</configuration>

Expand Down Expand Up @@ -187,6 +196,7 @@ Note though that this will also completely ignore package removals, as in that c

|Configuration Property | Description |
| --- | --- |
|`baseCoordinates` | The Maven coordinates of the base artifact in the format `<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}`. If set, takes precedence over {@code base}. Override with property `bnd.baseline.baseCoordinates`. Available since version 7.0.0 |
|`base` | See [Changing the baseline search parameters](#changing-the-baseline-search-parameters). _Defaults to the highest version of the project's artifact that is less than the version of the project's artifact._|
|`failOnMissing` | See [Fail on missing baseline](#fail-on-missing-baseline). _Defaults to `true`._ Override with property `bnd.baseline.fail.on.missing`.|
|`includeDistributionManagement`| See [Include Distribution Management](#include-distribution-management). _Defaults to `true`._ Override with property `bnd.baseline.include.distribution.management`.|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
invoker.goals=--no-transfer-progress verify
invoker.goals=--no-transfer-progress verify -Dbnd.baseline.baseCoordinates=biz.aQute.bnd-test:valid-no-previous:1.0.1

# Run mvn with --debug for debug logging
#invoker.debug=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
<configuration>
<base>
<artifactId>valid-no-previous</artifactId>
</base>
<!-- base configured via CLI argument -->
<includeDistributionManagement>true</includeDistributionManagement>
<continueOnError>true</continueOnError>
<fullReport>true</fullReport>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package aQute.bnd.maven.baseline.plugin;

import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.artifact.DefaultArtifact;

public class Base {

private String groupId;
Expand All @@ -12,6 +15,14 @@ public class Base {

private String extension;

public void setFromCoordinates(String coordinates) {
Artifact artifact = new DefaultArtifact(coordinates);
setGroupId(artifact.getGroupId());
setArtifactId(artifact.getArtifactId());
setVersion(artifact.getVersion());
setClassifier(artifact.getClassifier());
setExtension(artifact.getExtension());
}
public String getGroupId() {
return groupId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ public class BaselineMojo extends AbstractMojo {
@Parameter(property = "bnd.baseline.continue.on.error", defaultValue = "false")
private boolean continueOnError;

@Parameter
/**
* The Maven coordinates of the base artifact in the format
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}. If
* set, takes precedence over {@link #base}.
*/
@Parameter(property = "bnd.baseline.baseCoordinates")
private String baseCoordinates;

@Parameter(required = false)
private Base base;

@Parameter(required = false, property = "bnd.baseline.diffignores")
Expand Down Expand Up @@ -164,6 +172,9 @@ private void setupBase(Artifact artifact) {
if (base == null) {
base = new Base();
}
if (baseCoordinates != null && !baseCoordinates.isBlank()) {
base.setFromCoordinates(baseCoordinates);
}
if (base.getGroupId() == null || base.getGroupId()
.isEmpty()) {
base.setGroupId(project.getGroupId());
Expand Down
13 changes: 13 additions & 0 deletions maven-plugins/bnd-plugin-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,19 @@
</dependency>
</dependencies>

<repositories>
<repository>
<id>bnd-snapshots</id>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://bndtools.jfrog.io/bndtools/libs-snapshot/</url>
</repository>
</repositories>

<build>
<pluginManagement>
<plugins>
Expand Down

0 comments on commit fa8858e

Please sign in to comment.