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.
Add support for Product Update-site names and a test-case for it
This a work-around to have eclipse-equinox/p2#353 available now and can be reverted once the mentioned change in P2 is available in Tycho.
- Loading branch information
1 parent
a9b7b40
commit 67ec704
Showing
4 changed files
with
280 additions
and
2 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
tycho-its/projects/product.update_repository/aProduct.product
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?pde version="3.5"?> | ||
|
||
<product uid="aProduct" id="org.eclipse.platform.ide" version="1.0.0" type="mixed" includeLaunchers="false" autoIncludeRequirements="true"> | ||
|
||
<configIni use="default"> | ||
</configIni> | ||
|
||
<launcherArgs> | ||
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts | ||
</vmArgsMac> | ||
</launcherArgs> | ||
|
||
<launcher> | ||
<win useIco="false"> | ||
<bmp/> | ||
</win> | ||
</launcher> | ||
|
||
<features> | ||
<feature id="org.eclipse.equinox.p2.rcp.feature"/> | ||
<feature id="org.eclipse.e4.rcp"/> | ||
</features> | ||
|
||
|
||
<repositories> | ||
<repository location="https://foo.bar.org" enabled="true" /> | ||
<repository location="https://foo.bar.org/releases" name="Latest release" enabled="true" /> | ||
<repository location="https://foo.bar.org/snapshots" name="Latest snapshot" enabled="false" /> | ||
</repositories> | ||
|
||
</product> |
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,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>foo.bar</groupId> | ||
<artifactId>aProduct</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>eclipse-repository</packaging> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<repositories> | ||
<repository> | ||
<id>eclipse-latest</id> | ||
<layout>p2</layout> | ||
<url>${target-platform}</url> | ||
</repository> | ||
</repositories> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-p2-director-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<executions> | ||
<execution> | ||
<id>materialize-products</id> | ||
<goals> | ||
<goal>materialize-products</goal> | ||
</goals> | ||
<configuration> | ||
<products> | ||
<product> | ||
<id>aProduct</id> | ||
</product> | ||
</products> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>archive-products</id> | ||
<goals> | ||
<goal>archive-products</goal> | ||
</goals> | ||
<configuration> | ||
<products> | ||
<product> | ||
<id>aProduct</id> | ||
</product> | ||
</products> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
tycho-its/src/test/java/org/eclipse/tycho/test/product/ProductUpdateRepositoryTest.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,66 @@ | ||
package org.eclipse.tycho.test.product; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.eclipse.tycho.TargetEnvironment; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.junit.Test; | ||
|
||
public class ProductUpdateRepositoryTest extends AbstractTychoIntegrationTest { | ||
|
||
private static Verifier testBuildVerifier; | ||
|
||
@Test | ||
public void build() throws Exception { | ||
testBuildVerifier = getVerifier("product.update_repository", true); | ||
testBuildVerifier.executeGoals(List.of("clean", "verify")); | ||
testBuildVerifier.verifyErrorFreeLog(); | ||
TargetEnvironment env = TargetEnvironment.getRunningEnvironment(); | ||
Path baseDir = Path.of(testBuildVerifier.getBasedir()); | ||
Path productPath = baseDir.resolve(Path.of("target", "products", "aProduct")); | ||
Path osPlatformPath = productPath.resolve(Path.of(env.getOs(), env.getWs(), env.getArch())); | ||
Path p2EnginePath = osPlatformPath.resolve(Path.of("p2", "org.eclipse.equinox.p2.engine")); | ||
|
||
List<UpdateSiteReference> expectedReferences = List.of( | ||
new UpdateSiteReference("https://foo.bar.org", null, true), | ||
new UpdateSiteReference("https://foo.bar.org/releases", "Latest release", true), | ||
new UpdateSiteReference("https://foo.bar.org/snapshots", "Latest snapshot", false)); | ||
|
||
assertUpdateRepositoryReferences(expectedReferences, | ||
p2EnginePath.resolve(".settings/org.eclipse.equinox.p2.artifact.repository.prefs")); | ||
assertUpdateRepositoryReferences(expectedReferences, | ||
p2EnginePath.resolve(".settings/org.eclipse.equinox.p2.metadata.repository.prefs")); | ||
|
||
assertUpdateRepositoryReferences(expectedReferences, p2EnginePath.resolve( | ||
"profileRegistry/DefaultProfile.profile/.data/.settings/org.eclipse.equinox.p2.artifact.repository.prefs")); | ||
assertUpdateRepositoryReferences(expectedReferences, p2EnginePath.resolve( | ||
"profileRegistry/DefaultProfile.profile/.data/.settings/org.eclipse.equinox.p2.metadata.repository.prefs")); | ||
} | ||
|
||
private record UpdateSiteReference(String uri, String name, boolean enabled) { | ||
} | ||
|
||
private static void assertUpdateRepositoryReferences(List<UpdateSiteReference> expectedReferences, Path path) | ||
throws IOException { | ||
List<String> prefLines = Files.readAllLines(path); | ||
for (UpdateSiteReference reference : expectedReferences) { | ||
String preferencePrefix = "repositories/" + reference.uri.replace(":", "\\:").replace("/", "_"); | ||
assertThat(prefLines, hasItem(preferencePrefix + "/uri=" + reference.uri.replace(":", "\\:"))); | ||
assertThat(prefLines, hasItem(preferencePrefix + "/enabled=" + reference.enabled)); | ||
if (reference.name != null) { | ||
assertThat(prefLines, hasItem(preferencePrefix + "/nickname=" + reference.name)); | ||
} else { | ||
assertFalse(prefLines.stream().anyMatch(l -> l.startsWith(preferencePrefix + "/nickname="))); | ||
} | ||
} | ||
} | ||
|
||
} |