Throw an exception if SLC-Origin-M2-Merge is not set
[cc0/argeo-build.git] / src / org / argeo / build / Repackage.java
index 588b0b81197139b827cfa2e4d6c9b299fa7bf8f6..51d125ea1a7a55c1f01862c4520c05b33669eda1 100644 (file)
@@ -310,6 +310,10 @@ public class Repackage {
                mergeProps.put(ManifestConstants.BUNDLE_VERSION.toString(), m2Version);
 
                String artifactsStr = mergeProps.getProperty(ManifestConstants.SLC_ORIGIN_M2_MERGE.toString());
+               if (artifactsStr == null)
+                       throw new IllegalArgumentException(
+                                       mergeBnd + ": " + ManifestConstants.SLC_ORIGIN_M2_MERGE + " must be set");
+               
                String repoStr = mergeProps.containsKey(SLC_ORIGIN_M2_REPO.toString())
                                ? mergeProps.getProperty(SLC_ORIGIN_M2_REPO.toString())
                                : null;
@@ -366,8 +370,7 @@ public class Repackage {
                                                        try (OutputStream out = Files.newOutputStream(target, StandardOpenOption.APPEND)) {
                                                                out.write("\n".getBytes());
                                                                jarIn.transferTo(out);
-                                                               if (logger.isLoggable(DEBUG))
-                                                                       logger.log(DEBUG, artifact.getArtifactId() + " - Appended " + entry.getName());
+                                                               logger.log(Level.WARNING, artifact.getArtifactId() + " - Appended " + entry.getName());
                                                        }
                                                } else if (entry.getName().startsWith("org/apache/batik/")) {
                                                        logger.log(Level.WARNING, "Skip " + entry.getName());
@@ -392,8 +395,7 @@ public class Repackage {
                                                OutputStream out = Files.newOutputStream(target, StandardOpenOption.APPEND);) {
                                        out.write("\n".getBytes());
                                        in.transferTo(out);
-                                       if (logger.isLoggable(DEBUG))
-                                               logger.log(DEBUG, "Appended " + p);
+                                       logger.log(Level.WARNING, "Appended " + p);
                                }
                        }
                }
@@ -509,11 +511,15 @@ public class Repackage {
                        throws IOException {
                if (sourceBundles)
                        return;
-               M2Artifact sourcesArtifact = new M2Artifact(artifact.toM2Coordinates(), "sources");
-               URL sourcesUrl = M2ConventionsUtils.mavenRepoUrl(repoStr, sourcesArtifact);
-               Path sourcesDownloaded = download(sourcesUrl, originBase, artifact, true);
-               processM2SourceJar(sourcesDownloaded, targetBundleDir);
-               logger.log(Level.TRACE, () -> "Processed source " + sourcesDownloaded);
+               try {
+                       M2Artifact sourcesArtifact = new M2Artifact(artifact.toM2Coordinates(), "sources");
+                       URL sourcesUrl = M2ConventionsUtils.mavenRepoUrl(repoStr, sourcesArtifact);
+                       Path sourcesDownloaded = download(sourcesUrl, originBase, artifact, true);
+                       processM2SourceJar(sourcesDownloaded, targetBundleDir);
+                       logger.log(Level.TRACE, () -> "Processed source " + sourcesDownloaded);
+               } catch (Exception e) {
+                       logger.log(Level.ERROR, () -> "Cannot download source for  " + artifact);
+               }
 
        }
 
@@ -835,7 +841,8 @@ public class Repackage {
                                Object previousValue = manifest.getMainAttributes().putValue(key, value);
                                if (previousValue != null && !previousValue.equals(value)) {
                                        if (ManifestConstants.IMPORT_PACKAGE.toString().equals(key)
-                                                       || ManifestConstants.EXPORT_PACKAGE.toString().equals(key))
+                                                       || ManifestConstants.EXPORT_PACKAGE.toString().equals(key)
+                                                       || ManifestConstants.BUNDLE_LICENSE.toString().equals(key))
                                                logger.log(Level.TRACE, file.getFileName() + ": " + key + " was modified");
                                        else
                                                logger.log(Level.WARNING, file.getFileName() + ": " + key + " was " + previousValue