]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/NormalizeGroup.java
Change workspace names
[gpl/argeo-slc.git] / runtime / org.argeo.slc.repo / src / main / java / org / argeo / slc / repo / osgi / NormalizeGroup.java
index 57cc1145c9f2e909b6c4f5c8d47f5dee19bce35d..347e79be9917c2a13fc464060d75dc90828ae42a 100644 (file)
@@ -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;
+       private String parentPomCoordinates;
+
+       private List<String> excludedSuffixes = new ArrayList<String>();
 
        private ArtifactIndexer artifactIndexer = new ArtifactIndexer();
        private JarFileIndexer jarFileIndexer = new JarFileIndexer();
@@ -155,8 +157,10 @@ public class NormalizeGroup implements Runnable, SlcNames {
                        Set<Artifact> 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,7 +201,14 @@ 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));
+
+               if (bundleNode.getSession().hasPendingChanges())
+                       bundleNode.getSession().save();
        }
 
        protected void processBundleArtifact(Node bundleNode)
@@ -355,4 +372,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<String> excludedSuffixes) {
+               this.excludedSuffixes = excludedSuffixes;
+       }
+
 }