]> git.argeo.org Git - cc0/argeo-build.git/blobdiff - src/org/argeo/build/Repackage.java
Fix sources base directory in Repackage
[cc0/argeo-build.git] / src / org / argeo / build / Repackage.java
index 35413fe336df06dee5008f9fba2b827eba98e8a0..b0e667716d91fb42e4ea3ad22105b92cbc757fc9 100644 (file)
@@ -82,6 +82,7 @@ public class Repackage {
 
        private Path originBase;
        private Path a2Base;
+       private Path a2SrcBase;
        private Path a2LibBase;
        private Path descriptorsBase;
 
@@ -102,6 +103,7 @@ public class Repackage {
                this.originBase = Paths.get(System.getProperty("user.home"), ".cache", "argeo/build/origin");
                // TODO define and use a build base
                this.a2Base = a2Base;
+               this.a2SrcBase = a2Base.getParent().resolve(a2Base.getFileName() + ".src");
                this.a2LibBase = a2Base.resolve("lib");
                this.descriptorsBase = descriptorsBase;
                if (!Files.exists(this.descriptorsBase))
@@ -1008,12 +1010,19 @@ public class Repackage {
                deleteDirectory(bundleDir);
 
                if (sourceBundles) {
-                       Path sourceDir = bundleDir.getParent().resolve(bundleDir.toString() + ".src");
+                       Path bundleCategoryDir = bundleDir.getParent();
+                       Path sourceDir = bundleCategoryDir.resolve(bundleDir.toString() + ".src");
                        if (!Files.exists(sourceDir)) {
                                logger.log(WARNING, sourceDir + " does not exist, skipping...");
                                return jarPath;
+
                        }
-                       Path srcJarP = sourceDir.getParent().resolve(sourceDir.getFileName() + ".jar");
+
+                       Path relPath = a2Base.relativize(bundleCategoryDir);
+                       Path srcCategoryDir = a2SrcBase.resolve(relPath);
+                       Path srcJarP = srcCategoryDir.resolve(sourceDir.getFileName() + ".jar");
+                       Files.createDirectories(srcJarP.getParent());
+
                        String bundleSymbolicName = manifest.getMainAttributes().getValue("Bundle-SymbolicName").toString();
                        // in case there are additional directives
                        bundleSymbolicName = bundleSymbolicName.split(";")[0];