From 9ba09a3546e06a7ed84115b7e94ece08ee48f47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 28 Jul 2023 08:47:50 +0200 Subject: [PATCH] Return the packed project artifact as the location of the Artifact --- .../osgitools/DefaultArtifactDescriptor.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultArtifactDescriptor.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultArtifactDescriptor.java index 455109df5a..3c0fc4c62f 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultArtifactDescriptor.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultArtifactDescriptor.java @@ -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); @@ -79,16 +77,28 @@ public File getLocation(boolean fetch) { return location; } - @Override - public CompletableFuture 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 fetchArtifact() { + File projectLocation = getProjectLocation(); + if (projectLocation != null) { + return CompletableFuture.completedFuture(projectLocation); + } if (location != null && location.exists()) { return CompletableFuture.completedFuture(location); } @@ -109,19 +119,14 @@ public CompletableFuture fetchArtifact() { @Override public Optional 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(); }