Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bnd-baseline-maven-plugin doesn't baseline against version ranges #2315

Closed
anselmov opened this issue Feb 20, 2018 · 8 comments · Fixed by #2316
Closed

bnd-baseline-maven-plugin doesn't baseline against version ranges #2315

anselmov opened this issue Feb 20, 2018 · 8 comments · Fixed by #2316
Assignees
Milestone

Comments

@anselmov
Copy link

anselmov commented Feb 20, 2018

As an eclipse bndtools user, I expect the bnd-baseline-maven-plugin to work similarly and baseline against the highest version (latest).

My test is based on valid-no-previous integration-test. I did the following steps:

  1. change the project version to 1.0.0, run mvn install (to local repository), build success
  2. same code, change the project version to 3.0.0, run mvn install, build success
  3. same code, change the project version to 2.0.0, run mvn install, build success

The step 3 should fail but it baselines against 1.0.0 because the default base search range is:

(,${project.version})

I want to baseline against the highest version, so when I override the range in the plugin configuration:

<configuration>
    <base>
          <groupId>${project.groupId}</groupId>
          <artifactId>${project.artifactId}</artifactId>
          <version>(${project.version},)</version>
    </base>
</configuration>

I clean the .m2 repository, redo steps 1 and 2, then mvn verify and I get

Failed to execute goal biz.aQute.bnd:bnd-baseline-maven-plugin:4.0.0-SNAPSHOT:baseline (baseline) on project test: Unable to locate a previous version of the artifact: Could not find artifact org.example:test:jar:(2.0.0,) in central (file:///Users/anselmov/.m2/repository)

I'm not sure if my expectations are too high, but version ranges seem not handled properly. Any help is appreciated.

mvn version: 3.3.3
java version: 1.8.0_152-ea
OSX 10.9.5

@rotty3000
Copy link
Contributor

doesn't (2.0.0,) mean > 2.0.0 & < 3.0.0 (i.e. 2.0.x -> 2.x.x) which does not match 3.0.0?

@anselmov
Copy link
Author

anselmov commented Feb 20, 2018

(2.0.0,) means > 2.0.0, I did some tests with:

Artifact toCheck = toFind.setVersion("(," + artifact.getVersion() + ")");

There is a workaround when the default range is "any version" like:
Artifact toCheck = toFind.setVersion("[0,)");

btw: do you know why this single change makes integration-tests fail?

[INFO] Reactor Summary:
[INFO]
[INFO] test ............................................... SUCCESS [ 0.404 s]
[INFO] valid-no-previous .................................. SUCCESS [ 2.020 s]
[INFO] valid-with-previous-same ........................... SUCCESS [ 0.184 s]
[INFO] valid-with-provider ................................ SUCCESS [ 0.123 s]
[INFO] invalid-with-provider .............................. SUCCESS [ 0.147 s]
[INFO] invalid-with-consumer .............................. SUCCESS [ 0.126 s]
.....
Execution integration-test of goal org.apache.maven.plugins:maven-invoker-plugin:3.0.1:run failed: character 27 is not allowed in output

@bjhargrave
Copy link
Member

doesn't (2.0.0,) mean > 2.0.0 & < 3.0.0 (i.e. 2.0.x -> 2.x.x) which does not match 3.0.0?

See http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html. (x,) means versions > x.

But using (2,) as the version range for the baseline jar seems wrong. You want to baseline against the highest version LESS THAN the version you are currently building. This is why (,${project.version}) is used. There is an issue (#2248) which complains that SNAPSHOT can be used for the baseline. This needs to be fixed since SNAPSHOTs are, by definition, not released versions.

@bjhargrave
Copy link
Member

But I do see that the plugin does not correctly handle using versions in the configuration. I am looking at a fix now.

@anselmov
Copy link
Author

You want to baseline against the highest version LESS THAN the version you are currently building.

In bndtools, the default behavior is to baseline against the latest version in the repository, so we can't release a version between two existing versions. Can you confirm that this difference is intentional?

@bjhargrave bjhargrave self-assigned this Feb 20, 2018
@bjhargrave bjhargrave added this to the 4.0 milestone Feb 20, 2018
@bjhargrave
Copy link
Member

In bndtools, the default behavior is to baseline against the latest version in the repository, so we can't release a version between two existing versions. Can you confirm that this difference is intentional?

I don't know what Bndtools does here. Sorry.

@bjhargrave
Copy link
Member

With the fix in #2316, you can specify a range in the configuration and the baseline will use the highest version in the range.

@timothyjward
Copy link
Contributor

Just to confirm what others are saying:

I want to baseline against the highest version, so when I override the range in the plugin configuration:

<configuration>
    <base>
          <groupId>${project.groupId}</groupId>
          <artifactId>${project.artifactId}</artifactId>
          <version>(${project.version},)</version>
    </base>
 </configuration>

This is a really bad way to set up your build. Maven builds are supposed to be repeatable in the future so you should never attempt to baseline against a version that is higher than the version being built. Imagine, for example, that you release version 1.0.0, then later you release version 1.1.0. At this point you can no longer rebuild the tagged version 1.0.0 (or any 1.0.x fixes) because it will fail baselining against 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants