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

fix #2877 #2878

Merged
merged 6 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and the minimal reproducer project to Tycho's [issue tracker](https://github.com

### Prerequisites

Java 11 and Maven 3.6.3, or newer.
Java 17 and Maven 3.9.0, or newer.

If your Internet connection uses a proxy, make sure that you have the proxy configured in your [Maven settings.xml](https://maven.apache.org/settings.html).

Expand Down
5 changes: 5 additions & 0 deletions tycho-api/src/main/java/org/eclipse/tycho/TychoConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Contributors:
* Sonatype Inc. - initial API and implementation
* Christoph Läubrich - Issue #658 - Tycho strips p2 artifact properties (eg PGP, maven info...)
* Marco Lehmann-Mörz - issue #2877 - tycho-versions-plugin:bump-versions does not honor SNAPSHOT suffix
*******************************************************************************/
package org.eclipse.tycho;

Expand Down Expand Up @@ -133,4 +134,8 @@ public interface TychoConstants {
public String ROOTFILE_EXTENSION = "zip";

String HEADER_TESTCASES = "Test-Cases";

String SUFFIX_QUALIFIER = ".qualifier";

String SUFFIX_SNAPSHOT = "-SNAPSHOT";
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.ArtifactDependencyWalker;

public abstract class AbstractArtifactBasedProject extends AbstractTychoProject {
// this is stricter than Artifact.SNAPSHOT_VERSION
public static final String SNAPSHOT_VERSION = "-SNAPSHOT";
public static final String SNAPSHOT_VERSION = TychoConstants.SUFFIX_SNAPSHOT;

// requires resolved target platform
@Override
Expand All @@ -36,7 +37,8 @@ protected abstract ArtifactDependencyWalker newDependencyWalker(ReactorProject p
protected String getOsgiVersion(ReactorProject project) {
String version = project.getVersion();
if (version.endsWith(SNAPSHOT_VERSION)) {
version = version.substring(0, version.length() - SNAPSHOT_VERSION.length()) + ".qualifier";
version = version.substring(0, version.length() - SNAPSHOT_VERSION.length())
+ TychoConstants.SUFFIX_QUALIFIER;
}
return version;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Sonatype Inc. and others.
* Copyright (c) 2008, 2013 Sonatype Inc. and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* Sonatype Inc. - initial API and implementation
* Marco Lehmann-Mörz - issue #2877 - tycho-versions-plugin:bump-versions does not honor SNAPSHOT suffix
*******************************************************************************/
package org.eclipse.tycho.p2resolver;

Expand All @@ -30,6 +31,7 @@
import org.eclipse.tycho.IArtifactFacade;
import org.eclipse.tycho.OptionalResolutionAction;
import org.eclipse.tycho.TargetEnvironment;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.publisher.TychoMavenPropertiesAdvice;
import org.eclipse.tycho.core.shared.MavenContext;
import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator;
Expand All @@ -42,9 +44,6 @@
@Component(role = DependencyMetadataGenerator.class, hint = DependencyMetadataGenerator.SOURCE_BUNDLE)
public class SourcesBundleDependencyMetadataGenerator extends AbstractMetadataGenerator
implements DependencyMetadataGenerator {
private static final String SUFFIX_QUALIFIER = ".qualifier";

private static final String SUFFIX_SNAPSHOT = "-SNAPSHOT";

@Requirement
private MavenContext mavenContext;
Expand Down Expand Up @@ -110,8 +109,9 @@ private static String toCanonicalVersion(String version) {
if (version == null) {
return null;
}
if (version.endsWith(SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - SUFFIX_SNAPSHOT.length()) + SUFFIX_QUALIFIER;
if (version.endsWith(TychoConstants.SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - TychoConstants.SUFFIX_SNAPSHOT.length())
+ TychoConstants.SUFFIX_QUALIFIER;
}
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public abstract class AbstractTychoMapping implements Mapping, ModelReader {
protected static final String TYCHO_POMLESS_AGGREGATOR_NAMES_PROPERTY = "tycho.pomless.aggregator.names";

private static final String PARENT_POM_DEFAULT_VALUE = System.getProperty(TYCHO_POMLESS_PARENT_PROPERTY, "..");
private static final String QUALIFIER_SUFFIX = ".qualifier";
private static final String MODEL_PARENT = "TychoMapping.model.parent";

@Requirement
Expand Down Expand Up @@ -344,12 +343,12 @@ private static void setLocation(Model model, Path modelSource) {

protected String getPomVersion(String pdeVersion) {
String pomVersion = pdeVersion;
if (pdeVersion.endsWith(QUALIFIER_SUFFIX)) {
if (pdeVersion.endsWith(TychoConstants.QUALIFIER_SUFFIX)) {
String unqualifiedVersion = pdeVersion.substring(0, pdeVersion.length() - QUALIFIER_SUFFIX.length());
if (isExtensionMode() && snapshotFormat != null) {
return unqualifiedVersion + snapshotFormat;
}
return unqualifiedVersion + "-SNAPSHOT";
return unqualifiedVersion + TychoConstants.SNAPSHOT_SUFFIX;
}
return pomVersion;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Rapicorp, Inc. and others.
* Copyright (c) 2015, 2023 Rapicorp, Inc. and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -9,6 +9,7 @@
*
* Contributors:
* Rapicorp, Inc. - initial API and implementation
* Marco Lehmann-Mörz - issue #2877 - tycho-versions-plugin:bump-versions does not honor SNAPSHOT suffix
*******************************************************************************/
package org.eclipse.tycho.packaging;

Expand All @@ -23,6 +24,7 @@
import org.eclipse.tycho.ArtifactType;
import org.eclipse.tycho.IllegalArtifactReferenceException;
import org.eclipse.tycho.TargetPlatform;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.model.IU;

import de.pdark.decentxml.Element;
Expand Down Expand Up @@ -72,7 +74,7 @@ public void replaceQualifierInCapabilities(List<Element> providedCapabilities, S
private boolean hasQualifier(String v) {
if (v == null)
return false;
return v.endsWith(".qualifier");
return v.endsWith(TychoConstants.SUFFIX_QUALIFIER);
}

public void replaceQualifierInRequirements(IU iu, TargetPlatform targetPlatform) throws MojoFailureException {
Expand All @@ -81,7 +83,7 @@ public void replaceQualifierInRequirements(IU iu, TargetPlatform targetPlatform)
return;
for (Element req : requirements) {
String range = req.getAttributeValue(IU.RANGE);
if (range != null && range.endsWith(".qualifier")
if (range != null && range.endsWith(TychoConstants.SUFFIX_QUALIFIER)
&& IU.P2_IU_NAMESPACE.equals(req.getAttributeValue(IU.NAMESPACE))) {
ArtifactKey artifact = resolveRequirementReference(targetPlatform, req.getAttributeValue(IU.NAME),
range, req.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public void buildEnded(MavenSession session) {
String newVersion = suggestedVersion.map(String::valueOf)
.orElseGet(() -> Versions.incrementVersion(currentVersion,
VersionBumpMojo.getIncrement(session, project, projectHelper)));
boolean isSnapshot = currentVersion.endsWith(Versions.SUFFIX_SNAPSHOT);
if (isSnapshot) {
newVersion += Versions.SUFFIX_SNAPSHOT;
}
logger.info(project.getId() + " requires a version bump from " + currentVersion + " => "
+ newVersion);
engine.setProjects(metadataReader.getProjects());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Sonatype Inc. and others.
* Copyright (c) 2011, 2023 Sonatype Inc. and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand All @@ -9,39 +9,38 @@
*
* Contributors:
* Sonatype Inc. - initial API and implementation
* Marco Lehmann-Mörz - issue #2877 - tycho-versions-plugin:bump-versions does not honor SNAPSHOT suffix
*******************************************************************************/
package org.eclipse.tycho.versions.engine;

import java.io.File;

import org.eclipse.tycho.TychoConstants;
import org.osgi.framework.Version;

public class Versions {
private static final String SUFFIX_QUALIFIER = ".qualifier";

private static final String SUFFIX_SNAPSHOT = "-SNAPSHOT";

public static String toCanonicalVersion(String version) {
if (version == null) {
return null;
}

if (version.endsWith(SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - SUFFIX_SNAPSHOT.length()) + SUFFIX_QUALIFIER;
if (version.endsWith(TychoConstants.SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - TychoConstants.SUFFIX_SNAPSHOT.length())
+ TychoConstants.SUFFIX_QUALIFIER;
}

return version;
}

public static String incrementVersion(String version, int increment) {
boolean isSnapshot = version.endsWith(SUFFIX_SNAPSHOT);
boolean isSnapshot = version.endsWith(TychoConstants.SUFFIX_SNAPSHOT);
if (isSnapshot) {
version = version.substring(0, version.length() - SUFFIX_SNAPSHOT.length());
version = version.substring(0, version.length() - TychoConstants.SUFFIX_SNAPSHOT.length());
}
Version osgi = new Version(version);
String incremented = osgi.getMajor() + "." + osgi.getMinor() + "." + (osgi.getMicro() + increment);
if (isSnapshot) {
incremented += SUFFIX_SNAPSHOT;
incremented += TychoConstants.SUFFIX_SNAPSHOT;
}
return incremented;
}
Expand All @@ -54,11 +53,11 @@ public static String toBaseVersion(String version) {
return null;
}

if (version.endsWith(SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - SUFFIX_SNAPSHOT.length());
if (version.endsWith(TychoConstants.SUFFIX_SNAPSHOT)) {
return version.substring(0, version.length() - TychoConstants.SUFFIX_SNAPSHOT.length());
}
if (version.endsWith(SUFFIX_QUALIFIER)) {
return version.substring(0, version.length() - SUFFIX_QUALIFIER.length());
if (version.endsWith(TychoConstants.SUFFIX_QUALIFIER)) {
return version.substring(0, version.length() - TychoConstants.SUFFIX_QUALIFIER.length());
}

return version;
Expand All @@ -74,8 +73,9 @@ public static String toMavenVersion(String version) {
return null;
}

if (version.endsWith(SUFFIX_QUALIFIER)) {
return version.substring(0, version.length() - SUFFIX_QUALIFIER.length()) + SUFFIX_SNAPSHOT;
if (version.endsWith(TychoConstants.SUFFIX_QUALIFIER)) {
return version.substring(0, version.length() - TychoConstants.SUFFIX_QUALIFIER.length())
+ TychoConstants.SUFFIX_SNAPSHOT;
}

return version;
Expand Down