Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biz.aQute.bndlib/src/aQute/bnd/build/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,7 @@ public Container getDeliverable(String bsn, Map<String, String> attrs) throws Ex
for (Builder b : pb.getSubBuilders()) {
if (b.getBsn()
.equals(bsn)) {
String version = b.getVersion();
String version = getVersion(bsn).toString();
Container c = new Container(this, bsn, version, Container.TYPE.PROJECT, getOutputFile(bsn, version),
null, attrs, null);
return c;
Expand Down
57 changes: 29 additions & 28 deletions biz.aQute.bndlib/src/aQute/bnd/osgi/Builder.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,38 +470,12 @@ public void analyze() throws Exception {
String version = getProperty(BUNDLE_VERSION);
if (version != null) {
version = cleanupVersion(version);
version = doSnapshot(version);
version = doSnapshot(version, getProperty(Constants.SNAPSHOT));
setProperty(BUNDLE_VERSION, version);
}
}

private String doSnapshot(String version) {
String snapshot = getProperty(SNAPSHOT);
if (snapshot == null) {
return version;
}
if (snapshot.isEmpty()) {
snapshot = null;
}
Version v = Version.parseVersion(version);
String q = v.getQualifier();
if (q == null) {
return version;
}
if (q.equals("SNAPSHOT")) {
q = snapshot;
} else if (q.endsWith("-SNAPSHOT")) {
int end = q.length() - "SNAPSHOT".length();
if (snapshot == null) {
q = q.substring(0, end - 1);
} else {
q = q.substring(0, end) + snapshot;
}
} else {
return version;
}
return new Version(v.getMajor(), v.getMinor(), v.getMicro(), q).toString();
}


public void cleanupVersion(Packages packages, String defaultVersion) {
cleanupVersion(packages, defaultVersion, "external");
Expand Down Expand Up @@ -2267,6 +2241,33 @@ private static boolean isIdentical(Resource a, Resource b) {
}
}

public static String doSnapshot(String version, String snapshot) {

if (snapshot == null) {
return version;
}
if (snapshot.isEmpty()) {
snapshot = null;
}
Version v = Version.parseVersion(version);
String q = v.getQualifier();
if (q == null) {
return version;
}
if (q.equals("SNAPSHOT")) {
q = snapshot;
} else if (q.endsWith("-SNAPSHOT")) {
int end = q.length() - "SNAPSHOT".length();
if (snapshot == null) {
q = q.substring(0, end - 1);
} else {
q = q.substring(0, end) + snapshot;
}
} else {
return version;
}
return new Version(v.getMajor(), v.getMinor(), v.getMicro(), q).toString();
}


}
1 change: 1 addition & 0 deletions biz.aQute.repository/src/aQute/p2/export/P2Export.java
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ private BundleId getFeatureId(Processor definition) {
}
}

version = Builder.doSnapshot(version, definition.get(Constants.SNAPSHOT));
return getBundleId(featureName, version);
}

Expand Down
10 changes: 5 additions & 5 deletions biz.aQute.repository/test/aQute/p2/export/P2PublisherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@ void testBasic() throws Exception {
Jar content = new Jar("content.jar", jar.getResource("content.jar")
.openInputStream());
Jar featureMain = new Jar("feature.jar",
jar.getResource("features/bndtools.main.feature_7.0.0.0000-SNAPSHOT.jar")
jar.getResource("features/bndtools.main.feature_7.0.0.0000-RC1.jar")
.openInputStream());
Jar featurePde = new Jar("feature.jar",
jar.getResource("features/bndtools.pde.feature_7.0.0.0000-SNAPSHOT.jar")
jar.getResource("features/bndtools.pde.feature_7.0.0.0000-RC1.jar")
.openInputStream())) {

Resource metainf = jar.getResource("META-INF/MANIFEST.MF");
assertNotNull(metainf);
// notice the timestamp portion 0000 which should be in
// MANIFEST.MF
assertEquals("7.0.0.0000-SNAPSHOT", jar.getManifest()
assertEquals("7.0.0.0000-RC1", jar.getManifest()
.getMainAttributes()
.getValue(Constants.BUNDLE_VERSION));

// but in pom.properties we want just
// 7.0.0-SNAPSHOT (without the timestamp 0000 portion)
// 7.0.0-RC1(without the timestamp 0000 portion)
Resource pomproperties = jar.getResource("META-INF/maven/org.bndtools/org.bndtools.p2/pom.properties");
assertNotNull(pomproperties);
try (InputStream is = pomproperties.openInputStream()) {
String pomprops = new String(is.readAllBytes());
assertThat(pomprops).contains("groupId=org.bndtools");
assertThat(pomprops).contains("artifactId=org.bndtools.p2");
assertThat(pomprops).contains("version=7.0.0-SNAPSHOT");
assertThat(pomprops).contains("version=7.0.0-RC1");
}

InputStream xmlArtifactsIs = artifacts.getResource("artifacts.xml")
Expand Down
4 changes: 3 additions & 1 deletion biz.aQute.repository/testdata/p2-publish/ws-1/cnf/build.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
locations ='${fileuri;${workspace}/cnf/repo/index.xml}'; \
name ='P2'

Bundle-Version 800
-snapshot: RC1
base.version: 7.0.0.0000
Bundle-Version: ${base.version}-SNAPSHOT


-groupid: org.bndtools
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<feature id="bndtools.main.feature" version="7.0.0.0000-SNAPSHOT" label="Bndtools" provider-name="bnd">
<feature id="bndtools.main.feature" version="7.0.0.0000-RC1" label="Bndtools" provider-name="bnd">
<description url="https://bnd.bndtools.org/"><![CDATA[OSGi Development Tools for Eclipse based on bnd.]]></description>
<copyright><![CDATA[Copyright bndtools]]></copyright>
<license url="https://opensource.org/licenses/Apache-2.0"><![CDATA[SPDX-License-Identifier: (Apache-2.0 OR EPL-2.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<feature id="bndtools.pde.feature" version="7.0.0.0000-SNAPSHOT" label="Bndtools PDE" provider-name="bnd">
<feature id="bndtools.pde.feature" version="7.0.0.0000-RC1" label="Bndtools PDE" provider-name="bnd">
<description url="https://bnd.bndtools.org/"><![CDATA[PDE integration for Bndtools]]></description>
<copyright><![CDATA[Copyright bndtools]]></copyright>
<license url="https://opensource.org/licenses/Apache-2.0"><![CDATA[Simple license description]]></license>
Expand All @@ -7,7 +7,7 @@
<discovery url="https://bndtools.jfrog.io/bndtools/update-latest" label="Bndtools Update Site"/>
</url>
<requires>
<import feature="bndtools.main.feature.feature.group" version="7.0.0.0000-SNAPSHOT" match="perfect"/>
<import feature="bndtools.main.feature.feature.group" version="7.0.0.0000-RC1" match="perfect"/>
<import feature="org.eclipse.pde.feature.group" version="3.14.1300" match="equivalent"/>
</requires>
<plugin id="bndtools.pde" version="[7.0.0.202306291715-SNAPSHOT,7.0.0.202306291715-SNAPSHOT]" unpack="false"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Bundle-SymbolicName: org.bndtools.p2
Bundle-Version 7.0.0.0000-SNAPSHOT
Bundle-License: \
ASL-2.0;\
file="license.txt";\
Expand Down