Skip to content

Commit

Permalink
Use the updated p2 metadata once the project is packed
Browse files Browse the repository at this point in the history
Currently Tycho always uses the INITIAL dependency metadata to compute
the preliminary target platform. As this metadata can change once the
project is packed (e.g. headers added / removed) this can lead to
problems in plugins that depend on the changed plugin because P2 sees
the updated metadata afterwards and fails.

This now distinguish both cases and used the SEED metadata if the
project was already packed.

Fix eclipse-tycho#3824
  • Loading branch information
laeubi committed May 31, 2024
1 parent 04f02e8 commit 215c64b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ public final int hashCode() {
return Objects.hash(getArtifactId(), getGroupId(), getVersion());
}

@Override
public String toString() {
return "ReactorProjectIdentities [GroupId=" + getGroupId() + ", ArtifactId=" + getArtifactId() + ", Version="
+ getVersion() + ", Basedir=" + getBasedir() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ public Map<String, IP2Artifact> generateMetadata(MavenProject project, boolean g
PublisherOptions options = new PublisherOptions();
options.setGenerateDownloadStats(generateDownloadStatsProperty);
options.setGenerateChecksums(generateChecksums);
Map<String, IP2Artifact> generatedMetadata = generateMetadata(artifacts, options, targetDir);
return generatedMetadata;
return generateMetadata(artifacts, options, targetDir);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorPro
Map<IInstallableUnit, Set<File>> duplicateReactorUIs = new HashMap<>();

for (ReactorProject project : reactorProjects) {
Set<IInstallableUnit> projectIUs = project.getDependencyMetadata(DependencyMetadataType.INITIAL);

if (projectIUs == null) {
Set<IInstallableUnit> projectIUs = getPreliminaryReactorProjectUIs(project);
if (projectIUs == null || projectIUs.isEmpty()) {
continue;
}
for (IInstallableUnit iu : projectIUs) {
Expand All @@ -589,6 +589,19 @@ private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorPro
return reactorUIs;
}

private Set<IInstallableUnit> getPreliminaryReactorProjectUIs(ReactorProject project) {
String packaging = project.getPackaging();
if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(packaging) || PackagingType.TYPE_ECLIPSE_FEATURE.equals(packaging)
|| PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging)) {
File artifact = project.getArtifact();
if (artifact != null && artifact.isFile()) {
//the project was already build, use the seed units as they include anything maybe updated by p2-metadata mojo
return project.getDependencyMetadata(DependencyMetadataType.SEED);
}
}
return project.getDependencyMetadata(DependencyMetadataType.INITIAL);
}

private void applyFilters(TargetPlatformFilterEvaluator filter, Collection<IInstallableUnit> collectionToModify,
Set<IInstallableUnit> reactorProjectUIs, ExecutionEnvironmentResolutionHints eeResolutionHints,
Set<IInstallableUnit> shadowedIus) {
Expand Down
1 change: 1 addition & 0 deletions tycho-its/projects/tycho-ds-dependency/.mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Dtycho.localArtifacts=ignore

0 comments on commit 215c64b

Please sign in to comment.