From e146631736be22397edf93f81f3218b5a178dc06 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 21 Jun 2012 15:45:02 +0000 Subject: [PATCH] Improve OSGi related processes git-svn-id: https://svn.argeo.org/slc/trunk@5340 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../java/org/argeo/slc/repo/RepoUtils.java | 9 +++++ .../slc/repo/maven/MavenConventionsUtils.java | 8 ++--- .../argeo/slc/repo/osgi/ImportBundlesZip.java | 35 ++++++++----------- .../argeo/slc/repo/osgi/NormalizeGroup.java | 32 +++++++++++++++-- 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java index ff7b13d8f..6d22cbe68 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoUtils.java @@ -286,4 +286,13 @@ public class RepoUtils implements SlcNames { private RepoUtils() { } + + /** If a source return the base bundle name, does not change otherwise */ + public static String extractBundleNameFromSourceName(String sourceBundleName) { + if (sourceBundleName.endsWith(".source")) + return sourceBundleName.substring(0, sourceBundleName.length() + - ".source".length()); + else + return sourceBundleName; + } } diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/MavenConventionsUtils.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/MavenConventionsUtils.java index 2bf08c5b3..06be9eca3 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/MavenConventionsUtils.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/MavenConventionsUtils.java @@ -95,7 +95,7 @@ public class MavenConventionsUtils { // XML header p.append("\n"); p.append("\n"); - p.append("4.0.0"); + p.append("4.0.0\n"); // Artifact if (parent != null) { @@ -148,9 +148,9 @@ public class MavenConventionsUtils { p.append("\n"); // Repositories - p.append("\n"); - p.append("argeohttp://maven.argeo.org/argeo\n"); - p.append("\n"); +// p.append("\n"); +// p.append("argeohttp://maven.argeo.org/argeo\n"); +// p.append("\n"); p.append("\n"); return p.toString(); diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ImportBundlesZip.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ImportBundlesZip.java index 092101a8d..a11f2439c 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ImportBundlesZip.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ImportBundlesZip.java @@ -22,7 +22,6 @@ import org.argeo.slc.SlcException; import org.argeo.slc.repo.ArtifactIndexer; import org.argeo.slc.repo.JarFileIndexer; import org.argeo.slc.repo.RepoUtils; -import org.argeo.slc.repo.maven.MavenConventionsUtils; import org.sonatype.aether.artifact.Artifact; import org.sonatype.aether.util.artifact.DefaultArtifact; @@ -53,14 +52,14 @@ public class ImportBundlesZip implements Runnable { session = repository.login(workspace); // clear - String groupPath = MavenConventionsUtils.groupPath( - artifactBasePath, groupId); - if (session.itemExists(groupPath)) { - session.getNode(groupPath).remove(); - session.save(); - if (log.isDebugEnabled()) - log.debug("Cleared " + groupPath); - } + // String groupPath = MavenConventionsUtils.groupPath( + // artifactBasePath, groupId); + // if (session.itemExists(groupPath)) { + // session.getNode(groupPath).remove(); + // session.save(); + // if (log.isDebugEnabled()) + // log.debug("Cleared " + groupPath); + // } zipIn = new ZipInputStream(url.openStream()); ZipEntry zipEntry = null; @@ -86,10 +85,15 @@ public class ImportBundlesZip implements Runnable { continue entries; } + String bundleName = RepoUtils.extractBundleNameFromSourceName(nv + .getName()); // skip excluded bundles and their sources - if (excludedBundles.contains(extractBundleNameFromSourceName(nv - .getName()))) + if (excludedBundles.contains(bundleName)) continue entries; + // for(String excludedBundle:excludedBundles){ + // if(bundleName.contains(excludedBundle)) + // continue entries; + // } Artifact artifact = new DefaultArtifact(groupId, nv.getName(), "jar", nv.getVersion()); @@ -115,15 +119,6 @@ public class ImportBundlesZip implements Runnable { } - /** If a source return the base bundle name, does not change otherwise */ - private String extractBundleNameFromSourceName(String sourceBundleName) { - if (sourceBundleName.endsWith(".source")) - return sourceBundleName.substring(0, sourceBundleName.length() - - ".source".length()); - else - return sourceBundleName; - } - public void setRepository(Repository repository) { this.repository = repository; } diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java index 57cc1145c..144c15987 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java @@ -59,8 +59,10 @@ public class NormalizeGroup implements Runnable, SlcNames { private String workspace; private String groupId; private String artifactBasePath = "/"; - private String version = "1.3.0"; - private String parentPomCoordinates = "org.argeo:parent:1.3.0"; + private String version = null;// = "1.3.0"; + private String parentPomCoordinates;// = "org.argeo:parent:1.3.0"; + + private List excludedSuffixes = new ArrayList(); private ArtifactIndexer artifactIndexer = new ArtifactIndexer(); private JarFileIndexer jarFileIndexer = new JarFileIndexer(); @@ -155,8 +157,10 @@ public class NormalizeGroup implements Runnable, SlcNames { Set artifacts) throws RepositoryException { Artifact artifact = new DefaultArtifact(groupId, artifactId, "pom", version); + Artifact parentArtifact = parentPomCoordinates != null ? new DefaultArtifact( + parentPomCoordinates) : null; String pom = MavenConventionsUtils.artifactsAsDependencyPom(artifact, - artifacts, new DefaultArtifact(parentPomCoordinates)); + artifacts, parentArtifact); Node node = RepoUtils.copyBytesAsArtifact( session.getNode(artifactBasePath), artifact, pom.getBytes()); artifactIndexer.index(node); @@ -178,6 +182,12 @@ public class NormalizeGroup implements Runnable, SlcNames { if (symbolicName.endsWith(".source")) { // TODO make a shared node with classifier 'sources' + String bundleName = RepoUtils + .extractBundleNameFromSourceName(symbolicName); + for (String excludedSuffix : excludedSuffixes) { + if (bundleName.endsWith(excludedSuffix)) + return;// skip adding to sources + } sources.add(RepoUtils.asArtifact(bundleNode)); return; } @@ -191,6 +201,10 @@ public class NormalizeGroup implements Runnable, SlcNames { } symbolicNamesToNodes.put(symbolicName, bundleNode); + for (String excludedSuffix : excludedSuffixes) { + if (symbolicName.endsWith(excludedSuffix)) + return;// skip adding to binaries + } binaries.add(RepoUtils.asArtifact(bundleNode)); } @@ -355,4 +369,16 @@ public class NormalizeGroup implements Runnable, SlcNames { this.parentPomCoordinates = parentPomCoordinates; } + public void setArtifactBasePath(String artifactBasePath) { + this.artifactBasePath = artifactBasePath; + } + + public void setVersion(String version) { + this.version = version; + } + + public void setExcludedSuffixes(List excludedSuffixes) { + this.excludedSuffixes = excludedSuffixes; + } + } -- 2.39.2