X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=src%2Forg%2Fargeo%2Fbuild%2FRepackage.java;h=9b847bab8d78ef5f6bb82ec877d9be1d683a5e24;hb=3fd6f8ff0f7261c67e528239fdb2f6d9e56a19a1;hp=8decd413908c2e715dce489e189e1239b4d98bf4;hpb=3197cc1f879f7723185dc9b534e469dd866c4f06;p=cc0%2Fargeo-build.git diff --git a/src/org/argeo/build/Repackage.java b/src/org/argeo/build/Repackage.java index 8decd41..9b847ba 100644 --- a/src/org/argeo/build/Repackage.java +++ b/src/org/argeo/build/Repackage.java @@ -232,12 +232,12 @@ public class Repackage { final Map> mirrors = new HashMap>(); /** Whether sources should be packaged separately */ - final boolean sourceBundles; + final boolean separateSources; /** Constructor initialises the various variables */ public Repackage(Path a2Base, Path descriptorsBase) { - sourceBundles = Boolean.parseBoolean(System.getenv(ENV_SOURCE_BUNDLES)); - if (sourceBundles) + separateSources = Boolean.parseBoolean(System.getenv(ENV_SOURCE_BUNDLES)); + if (separateSources) logger.log(INFO, "Sources will be packaged separately"); Objects.requireNonNull(a2Base); @@ -247,7 +247,7 @@ public class Repackage { // TODO define and use a build base this.a2Base = a2Base; - this.a2SrcBase = a2Base.getParent().resolve(a2Base.getFileName() + ".src"); + this.a2SrcBase = separateSources ? a2Base.getParent().resolve(a2Base.getFileName() + ".src") : a2Base; this.a2LibBase = a2Base.resolve("lib"); this.descriptorsBase = descriptorsBase; if (!Files.exists(this.descriptorsBase)) @@ -334,7 +334,7 @@ public class Repackage { boolean doNotModify = Boolean .parseBoolean(fileProps.getOrDefault(ARGEO_DO_NOT_MODIFY.toString(), "false").toString()); - if (doNotModify && sourceBundles) { + if (doNotModify) { processNotModified(targetCategoryBase, downloaded, fileProps, artifact); return; } @@ -429,8 +429,8 @@ public class Repackage { boolean doNotModify = Boolean .parseBoolean(mergedProps.getOrDefault(ARGEO_DO_NOT_MODIFY.toString(), "false").toString()); - if (doNotModify && sourceBundles) { - processNotModified(targetCategoryBase, downloaded, fileProps, artifact); + if (doNotModify) { + processNotModified(targetCategoryBase, downloaded, mergedProps, artifact); } else { A2Origin origin = new A2Origin(); Path targetBundleDir = processBndJar(downloaded, targetCategoryBase, mergedProps, artifact, origin); @@ -708,6 +708,7 @@ public class Repackage { // When releasing (with separate sources), we just copy it Path unmodifiedTarget = targetCategoryBase .resolve(fileProps.getProperty(BUNDLE_SYMBOLICNAME.toString()) + "." + artifact.getBranch() + ".jar"); + Files.createDirectories(unmodifiedTarget.getParent()); Files.copy(downloaded, unmodifiedTarget, StandardCopyOption.REPLACE_EXISTING); Path bundleDir = targetCategoryBase .resolve(fileProps.getProperty(BUNDLE_SYMBOLICNAME.toString()) + "." + artifact.getBranch()); @@ -742,7 +743,7 @@ public class Repackage { /** Integrate sources from a downloaded jar file. */ void processM2SourceJar(Path file, Path bundleDir, M2Artifact mergingFrom) throws IOException { A2Origin origin = new A2Origin(); - Path sourceDir = sourceBundles ? bundleDir.getParent().resolve(bundleDir.toString() + ".src") + Path sourceDir = separateSources ? bundleDir.getParent().resolve(bundleDir.toString() + ".src") : bundleDir.resolve("OSGI-OPT/src"); try (JarInputStream jarIn = new JarInputStream(Files.newInputStream(file), false)) { @@ -786,7 +787,7 @@ public class Repackage { } } // write the changes - if (sourceBundles) { + if (separateSources) { origin.appendChanges(sourceDir); } else { origin.added.add("source code under OSGI-OPT/src"); @@ -925,7 +926,7 @@ public class Repackage { NameVersion nameVersion = new NameVersion(relatedBundle[0], version); bundleDir = targetBase.resolve(nameVersion.getName() + "." + nameVersion.getBranch()); - Path sourceDir = sourceBundles ? bundleDir.getParent().resolve(bundleDir.toString() + ".src") + Path sourceDir = separateSources ? bundleDir.getParent().resolve(bundleDir.toString() + ".src") : bundleDir.resolve("OSGI-OPT/src"); Files.createDirectories(sourceDir); @@ -942,7 +943,7 @@ public class Repackage { } // write the changes - if (sourceBundles) { + if (separateSources) { origin.appendChanges(sourceDir); } else { origin.added.add("source code under OSGI-OPT/src"); @@ -1359,7 +1360,7 @@ public class Repackage { } deleteDirectory(bundleDir); - if (sourceBundles) + if (separateSources) createSourceJar(bundleDir, manifest, false); return jarPath; @@ -1471,7 +1472,7 @@ public class Repackage { writer.append("\nA detailed list of changes is available under " + CHANGES + ".\n"); if (!jarDir.getFileName().endsWith(".src")) {// binary archive - if (sourceBundles) + if (separateSources) writer.append("Corresponding sources are available in the related archive named " + jarDir.toString() + ".src.jar.\n"); else