Skip to content

Commit

Permalink
added ITs for referencedRepositoryMode
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini authored and laeubi committed Dec 14, 2023
1 parent 00c55f8 commit 1c542d0
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: p2Repository.repositoryRef.target;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.epsilon.picto
Bundle-Name: p2Repository.repositoryRef.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its-project.p2Repository.repositoryRef.targetresolution</groupId>
<artifactId>p2Repository.repositoryRef.target</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<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>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<file>
${project.basedir}/test-target.target
</file>
</target>
<referencedRepositoryMode>ignore</referencedRepositoryMode>
<!--
The project requires a bundle from Epsilon and Eclipse.
The target platform only uses the Epsilon update site.
Epsilon update site uses referenced repositories so using its update site alone
should be enough to resolve the transitive dependencies.
However, we explicitly ignore referenced sites, so this should lead to
a resolution failure -->
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="test-target.target" sequenceNumber="1">
<locations>
<!-- Epsilon update site uses referenced repositories so using its update site alone
should be enough to resolve the transitive dependencies -->
<location includeAllPlatforms="false" includeConfigurePhase="true"
includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.epsilon.picto"
version="0.0.0" />
<repository
location="https://download.eclipse.org/epsilon/updates/2.4/" />
</location>
</locations>
</target>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: p2Repository.repositoryRef.target;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.epsilon.picto
Bundle-Name: p2Repository.repositoryRef.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>tycho-its-project.p2Repository.repositoryRef.targetresolution</groupId>
<artifactId>p2Repository.repositoryRef.target</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<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>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<target>
<file>
${project.basedir}/test-target.target
</file>
</target>
<!-- The default is
<referencedRepositoryMode>include</referencedRepositoryMode>
The project requires a bundle from Epsilon and Eclipse.
The target platform only uses the Epsilon update site.
Epsilon update site uses referenced repositories so using its update site alone
should be enough to resolve the transitive dependencies-->
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.8"?>
<target name="test-target.target" sequenceNumber="1">
<locations>
<!-- Epsilon update site uses referenced repositories so using its update site alone
should be enough to resolve the transitive dependencies -->
<location includeAllPlatforms="false" includeConfigurePhase="true"
includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.epsilon.picto"
version="0.0.0" />
<repository
location="https://download.eclipse.org/epsilon/updates/2.4/" />
</location>
</locations>
</target>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -84,6 +85,25 @@ public void testAdditionOfOnlyProvidingRepos() throws Exception {
new RepositoryReference("https://download.eclipse.org/cbi/updates/license", TYPE_METADATA, ENABLED)));
}

@Test
public void testTargetResolutionWithReferencedRepositoryInclude() throws Exception {
// <referencedRepositoryMode>include</referencedRepositoryMode> is the default
Verifier verifier = getVerifier("/p2Repository.repositoryRef.targetresolution.include", false);
verifier.executeGoal("package");
verifier.verifyErrorFreeLog();
}

@Test
public void testTargetResolutionWithReferencedRepositoryIgnore() throws Exception {
Verifier verifier = getVerifier("/p2Repository.repositoryRef.targetresolution.ignore", false);
try {
verifier.executeGoal("package");
fail("Build should fail due to missing transitive dependency dependency");
} catch (VerificationException e) {
verifier.verifyTextInLog("requires 'osgi.bundle; org.eclipse.emf.ecore 0.0.0' but it could not be found");
}
}

private List<RepositoryReference> buildAndGetRepositoryReferences(String buildRoot, Consumer<Verifier> setup)
throws Exception, VerificationException {
Verifier verifier = getVerifier(buildRoot, false);
Expand Down

0 comments on commit 1c542d0

Please sign in to comment.