Skip to content
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

Return the packed project artifact as the location of the Artifact #2667

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.Stack;

Expand Down Expand Up @@ -99,10 +100,10 @@ protected void traverseFeature(File location, Feature feature, FeatureRef featur
}

protected ArtifactDescriptor getArtifact(File location, String id) {
Map<String, ArtifactDescriptor> artifacts = this.artifacts.getArtifact(location);
if (artifacts != null) {
for (ArtifactDescriptor artifact : artifacts.values()) {
if (id.equals(artifact.getKey().getId())) {
for (ArtifactDescriptor artifact : this.artifacts.getArtifacts()) {
if (id.equals(artifact.getKey().getId())) {
File other = getLocation(artifact);
if (Objects.equals(location, other)) {
return artifact;
}
}
Expand Down Expand Up @@ -179,8 +180,7 @@ protected void traverseFeature(FeatureRef ref, ArtifactDependencyVisitor visitor

visited.enter(artifact);
try {
File location = artifact.getLocation(true);

File location = getLocation(artifact);
Feature feature = Feature.loadFeature(location);
traverseFeature(location, feature, ref, visitor, visited);
} finally {
Expand All @@ -191,6 +191,15 @@ protected void traverseFeature(FeatureRef ref, ArtifactDependencyVisitor visitor
}
}

private File getLocation(ArtifactDescriptor artifact) {
ReactorProject mavenProject = artifact.getMavenProject();
if (mavenProject != null) {
return mavenProject.getBasedir();
} else {
return artifact.getLocation(true);
}
}

private void traversePlugin(PluginRef ref, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
if (!matchTargetEnvironment(ref)) {
return;
Expand All @@ -205,7 +214,7 @@ private void traversePlugin(PluginRef ref, ArtifactDependencyVisitor visitor, Wa
return;
}

File location = artifact.getLocation(true);
File location = getLocation(artifact);
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Collection<IInstallableUnit> installableUnits = artifact.getInstallableUnits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ public ArtifactKey getKey() {

@Override
public File getLocation(boolean fetch) {
if (project != null) {
File basedir = project.getBasedir();
if (basedir != null) {
return basedir;
}
File projectLocation = getProjectLocation();
if (projectLocation != null) {
return projectLocation;
}
if (fetch && locationSupplier != null && (location == null || !location.exists())) {
File file = locationSupplier.apply(this);
Expand All @@ -79,16 +77,28 @@ public File getLocation(boolean fetch) {
return location;
}

@Override
public CompletableFuture<File> fetchArtifact() {
private File getProjectLocation() {
if (project != null) {
File packedArtifact = project.getArtifact();
if (packedArtifact != null && packedArtifact.isFile()) {
return packedArtifact;
}
//TODO this really looks wrong! It should the file of the artifact (if present!) or the output directory,
// but the basedir most likely only works for tycho ...
File basedir = project.getBasedir();
if (basedir != null) {
return CompletableFuture.completedFuture(basedir);
return basedir;
}
}
return null;
}

@Override
public CompletableFuture<File> fetchArtifact() {
File projectLocation = getProjectLocation();
if (projectLocation != null) {
return CompletableFuture.completedFuture(projectLocation);
}
if (location != null && location.exists()) {
return CompletableFuture.completedFuture(location);
}
Expand All @@ -109,19 +119,14 @@ public CompletableFuture<File> fetchArtifact() {

@Override
public Optional<File> getLocation() {
if (project != null) {
//TODO this really looks wrong! It should the file of the artifact (if present!) or the output directory,
// but the basedir most likely only works for tycho ...
File basedir = project.getBasedir();
if (basedir != null) {
return Optional.of(basedir);
}
File projectLocation = getProjectLocation();
if (projectLocation != null) {
return Optional.of(projectLocation);
}
if (location != null) {
//TODO actually location.exists() should be used here! But some code has problems with that!
return Optional.of(location);
}
// TODO Auto-generated method stub
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<deployableFeature>true</deployableFeature>
</configuration>
Expand Down
4 changes: 3 additions & 1 deletion tycho-its/projects/multiPlatform.reactor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<artifactId>mpr.parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>bundle</module>
<module>feature</module>
Expand Down Expand Up @@ -35,7 +38,6 @@
<artifactId>target-platform-configuration</artifactId>
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
<environments>
<environment>
<os>win32</os>
Expand Down
Loading