-
Notifications
You must be signed in to change notification settings - Fork 194
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
Pr 2978 #2989
Merged
Merged
Pr 2978 #2989
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 7 additions & 0 deletions
7
tycho-its/projects/p2Inf.virtualUnit/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,7 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: pvu.bundle | ||
Bundle-SymbolicName: pvu.bundle;singleton:=true | ||
Bundle-Version: 1.0.0.qualifier | ||
Bundle-Vendor: TEST | ||
Bundle-RequiredExecutionEnvironment: JavaSE-17 |
11 changes: 11 additions & 0 deletions
11
tycho-its/projects/p2Inf.virtualUnit/bundle/META-INF/p2.inf
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,11 @@ | ||
# Create the virtual IU | ||
units.0.id=configure.pvu.bundle | ||
units.0.version=1.0.0 | ||
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu | ||
units.0.provides.1.name=configure.pvu.bundle | ||
units.0.provides.1.version=1.0.0 | ||
|
||
# Require in this bundle the created virtual IU | ||
requires.0.namespace=org.eclipse.equinox.p2.iu | ||
requires.0.name=configure.pvu.bundle | ||
requires.0.range=0.0.0 |
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 @@ | ||
bin.includes = META-INF/,\ | ||
. |
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,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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> | ||
|
||
<parent> | ||
<groupId>tycho-its-project.p2Inf.virtualUnit</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>pvu.bundle</artifactId> | ||
<packaging>eclipse-plugin</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>target-platform-configuration</artifactId> | ||
<version>${tycho-version}</version> | ||
<configuration> | ||
<pomDependencies>consider</pomDependencies> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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>tycho-its-project.p2Inf.virtualUnit</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<properties> | ||
<tycho-version>4.0.3</tycho-version> | ||
</properties> | ||
|
||
<modules> | ||
<module>bundle</module> | ||
</modules> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
80 changes: 80 additions & 0 deletions
80
tycho-its/src/test/java/org/eclipse/tycho/test/p2Inf/VirtualUnitTest.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,80 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Martin D'Aloia 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 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.test.p2Inf; | ||
|
||
import static java.util.Arrays.asList; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.junit.Test; | ||
|
||
import de.pdark.decentxml.Document; | ||
import de.pdark.decentxml.Element; | ||
import de.pdark.decentxml.XMLParser; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Test that a virtual IU created just with metadata in a p2.inf file can be required | ||
* in the same p2.inf file. | ||
* <p> | ||
* It used to work until 3.0.5 (using <code><pomDependencies>consider</pomDependencies></code>) | ||
* but since 4.0.0 failed with: | ||
* <pre> | ||
* Cannot resolve project dependencies: | ||
* Software being installed: pvu.bundle 1.0.0.qualifier | ||
* Missing requirement: pvu.bundle 1.0.0.qualifier requires 'org.eclipse.equinox.p2.iu; configure.pvu.bundle 0.0.0' but it could not be found | ||
* </pre> | ||
* | ||
* See https://github.com/eclipse-tycho/tycho/blob/master/RELEASE_NOTES.md#mixed-reactor-setups-require-the-new-resolver-now | ||
* and https://github.com/eclipse-tycho/tycho/issues/2977 | ||
*/ | ||
public class VirtualUnitTest extends AbstractTychoIntegrationTest { | ||
|
||
@Test | ||
public void testVirtualUnitRequirementDoesNotFailBuild() throws Exception { | ||
Verifier verifier = getVerifier("/p2Inf.virtualUnit", false); | ||
verifier.executeGoals(asList("verify")); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
String hostUnitId = "pvu.bundle"; | ||
String configureUnitId = "configure.pvu.bundle"; | ||
|
||
File p2Content = new File(verifier.getBasedir(), "bundle/target/p2content.xml"); | ||
Document doc = XMLParser.parse(p2Content); | ||
|
||
List<Element> units = doc.getChild("units").getChildren("unit"); | ||
Optional<Element> hostUnit = findUnit(units, hostUnitId); | ||
Optional<Element> configureUnit = findUnit(units, configureUnitId); | ||
|
||
Stream<Element> hostUnitRequirements = findRequirements(hostUnit); | ||
|
||
assertTrue("Host IU " + hostUnitId + " not found", hostUnit.isPresent()); | ||
assertTrue("Configure IU " + configureUnitId + " not found", configureUnit.isPresent()); | ||
assertTrue("Requirement of IU " + configureUnitId + " not found in IU " + hostUnitId, | ||
hostUnitRequirements.anyMatch(elem -> configureUnitId.equals(elem.getAttributeValue("name")))); | ||
} | ||
|
||
private static Optional<Element> findUnit(List<Element> units, String hostUnitId) { | ||
return units.stream() | ||
.filter(elem -> hostUnitId.equals(elem.getAttributeValue("id"))) | ||
.findFirst(); | ||
} | ||
|
||
private static Stream<Element> findRequirements(Optional<Element> hostUnit) { | ||
return hostUnit.stream().flatMap(elem -> elem.getChild("requires").getChildren("required").stream()); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this hardcoded version
1.0.0
irrelevant? what if the declared unit sets its version to anything else?(same below on the
else
branch of theif
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version is only used to check if the advice should be applied to a unit, as we are not interested in the advice itself but only the additional units it defines the version has actually no influence here.