forked from eclipse-tycho/tycho
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue eclipse-tycho#611 Support setting CI-Friendly-Versions in
tycho-build-extension Add a first implementation and integration test
- Loading branch information
Showing
15 changed files
with
269 additions
and
17 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
tycho-build/src/main/java/org/eclipse/tycho/build/TychoCiFriendlyVersions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Christoph Läubrich and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Christoph Läubrich - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.build; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Properties; | ||
import java.util.TimeZone; | ||
|
||
import javax.annotation.Priority; | ||
import javax.inject.Named; | ||
|
||
import org.apache.maven.model.building.ModelBuildingRequest; | ||
import org.apache.maven.model.interpolation.DefaultModelVersionProcessor; | ||
import org.apache.maven.model.interpolation.ModelVersionProcessor; | ||
|
||
@Priority(100) | ||
@Named | ||
public class TychoCiFriendlyVersions extends DefaultModelVersionProcessor implements ModelVersionProcessor { | ||
|
||
static final String BUILD_QUALIFIER = "qualifier"; | ||
static final String MICRO_VERSION = "micro"; | ||
static final String MINOR_VERSION = "minor"; | ||
static final String MAJOR_VERSION = "major"; | ||
static final String RELEASE_VERSION = "releaseVersion"; | ||
|
||
@Override | ||
public boolean isValidProperty(String property) { | ||
return super.isValidProperty(property) || MAJOR_VERSION.equals(property) || MINOR_VERSION.equals(property) | ||
|| MICRO_VERSION.equals(property) || BUILD_QUALIFIER.equals(property) | ||
|| RELEASE_VERSION.equals(property); | ||
} | ||
|
||
@Override | ||
public void overwriteModelProperties(Properties modelProperties, ModelBuildingRequest request) { | ||
super.overwriteModelProperties(modelProperties, request); | ||
if (request.getSystemProperties().containsKey(MAJOR_VERSION)) { | ||
modelProperties.put(MAJOR_VERSION, request.getSystemProperties().get(MAJOR_VERSION)); | ||
} | ||
if (request.getSystemProperties().containsKey(MINOR_VERSION)) { | ||
modelProperties.put(MINOR_VERSION, request.getSystemProperties().get(MINOR_VERSION)); | ||
} | ||
if (request.getSystemProperties().containsKey(MICRO_VERSION)) { | ||
modelProperties.put(MICRO_VERSION, request.getSystemProperties().get(MICRO_VERSION)); | ||
} | ||
if (request.getSystemProperties().containsKey(BUILD_QUALIFIER)) { | ||
modelProperties.put(BUILD_QUALIFIER, request.getSystemProperties().get(BUILD_QUALIFIER)); | ||
} else { | ||
Date startTime = request.getBuildStartTime(); | ||
if (startTime != null) { | ||
String formatString = request.getSystemProperties().getProperty("tycho.buildqualifier.format"); | ||
if (formatString != null) { | ||
SimpleDateFormat format = new SimpleDateFormat(formatString); | ||
format.setTimeZone(TimeZone.getTimeZone("UTC")); | ||
String qualifier = format.format(startTime); | ||
modelProperties.put(BUILD_QUALIFIER, "." + qualifier); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
tycho-its/projects/ci-friendly/buildqualifier.default/.mvn/extensions.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<extensions> | ||
<extension> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-build</artifactId> | ||
<version>${tycho-version}</version> | ||
</extension> | ||
</extensions> |
2 changes: 2 additions & 0 deletions
2
tycho-its/projects/ci-friendly/buildqualifier.default/.mvn/maven.config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-Dtycho-version=3.0.0-SNAPSHOT | ||
-Dtycho.buildqualifier.format=yyyyMMddHHmm |
8 changes: 8 additions & 0 deletions
8
tycho-its/projects/ci-friendly/buildqualifier.default/bundle/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: bundle Plug-in | ||
Bundle-SymbolicName: bundle | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Export-Package: bundle | ||
Automatic-Module-Name: bundle |
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/ci-friendly/buildqualifier.default/bundle/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = .,\ | ||
META-INF/ |
20 changes: 20 additions & 0 deletions
20
tycho-its/projects/ci-friendly/buildqualifier.default/bundle/src/bundle/Something.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 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 | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Sonatype Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle; | ||
|
||
public class Something { | ||
|
||
public static void sayHello() { | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
tycho-its/projects/ci-friendly/buildqualifier.default/bundle2/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: bundle2 | ||
Bundle-SymbolicName: bundle2;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Require-Bundle: bundle;bundle-version="1.0.0" | ||
Bundle-RequiredExecutionEnvironment: JavaSE-11 | ||
Automatic-Module-Name: bundle2 |
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/ci-friendly/buildqualifier.default/bundle2/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = .,\ | ||
META-INF/ |
23 changes: 23 additions & 0 deletions
23
tycho-its/projects/ci-friendly/buildqualifier.default/bundle2/src/bundle2/BundleClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021 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 | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Sonatype Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package bundle2; | ||
|
||
import bundle.Something; | ||
|
||
public class BundleClient { | ||
|
||
public void doSomething() { | ||
Something.sayHello(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
tycho-its/projects/ci-friendly/buildqualifier.default/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.eclipse.tycho.tycho-its</groupId> | ||
<artifactId>ci-friendly-parent</artifactId> | ||
<packaging>pom</packaging> | ||
<version>${releaseVersion}${qualifier}</version> | ||
<modules> | ||
<module>bundle</module> | ||
<module>bundle2</module> | ||
</modules> | ||
|
||
<properties> | ||
<!-- Define the release version used for unversioned items like pom file --> | ||
<releaseVersion>1.0.0</releaseVersion> | ||
<!-- Defines the default Qualifier if no format is given--> | ||
<qualifier>-SNAPSHOT</qualifier> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
tycho-its/src/test/java/org/eclipse/tycho/test/buildextension/CiFriendlyVersionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.eclipse.tycho.test.buildextension; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.junit.Test; | ||
|
||
public class CiFriendlyVersionsTest extends AbstractTychoIntegrationTest { | ||
|
||
@Test | ||
public void testDefaultBuildQualifier() throws Exception { | ||
Verifier verifier = getVerifier("ci-friendly/buildqualifier.default", false, true); | ||
verifier.executeGoals(List.of("clean", "package")); | ||
verifier.verifyErrorFreeLog(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.