From 66eb686f15b40d067aeb146f34e8dd4a82f8aa6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 1 Feb 2025 10:39:47 +0100 Subject: [PATCH] Use the main project to let bnd compute the output file Currently we compute the name of the subjar manually, but this can be overridden by the user so it is better to let bnd calculate the file itself. Additional init the global driver property of workspace. (cherry picked from commit c87caebe5906111a16eb937b2b932b476c36f615) --- .../main/java/org/eclipse/tycho/bnd/mojos/BndBuildMojo.java | 3 +-- .../src/main/java/org/eclipse/tycho/bnd/mojos/BndInitMojo.java | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndBuildMojo.java b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndBuildMojo.java index 4256f69c9f..cbdc1f910c 100644 --- a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndBuildMojo.java +++ b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndBuildMojo.java @@ -49,9 +49,8 @@ protected void execute(Project project) throws Exception { getLog().info(String.format("Building sub bundle '%s'", subProject.getName())); Jar jar = builder.build(); checkResult(builder, project.getWorkspace().isFailOk()); - String jarName = jar.getName(); String name = subProject.getName(); - File file = new File(mavenProject.getBuild().getDirectory(), String.format("%s.jar", jarName)); + File file = project.getOutputFile(builder.getBsn(), builder.getVersion()); file.getParentFile().mkdirs(); jar.write(file); helper.attachArtifact(mavenProject, "jar", name, file); diff --git a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndInitMojo.java b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndInitMojo.java index 37851c61b1..73a74a3519 100644 --- a/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndInitMojo.java +++ b/tycho-bnd-plugin/src/main/java/org/eclipse/tycho/bnd/mojos/BndInitMojo.java @@ -33,6 +33,8 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; +import aQute.bnd.build.Workspace; + @Mojo(name = "initialize", defaultPhase = LifecyclePhase.INITIALIZE) public class BndInitMojo extends AbstractMojo { @@ -74,6 +76,7 @@ public class BndInitMojo extends AbstractMojo { @Override public void execute() throws MojoExecutionException, MojoFailureException { + Workspace.setDriver("tycho-maven-build"); fixupPolyglot(); writeConsumerPom(); }