X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2Fmaven%2FImportMavenDependencies.java;h=19d7c8d8c2084f36fb0badccae551b3f715986ef;hb=aeaa45c7cfbb4f2376a4ec02e6dd71d711a52c5b;hp=bde774526c48354f35bb6e70ceb9292e54e493fe;hpb=496f697b423f25a732d7d2e5b0405cfed0c31393;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java index bde774526..19d7c8d8c 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/maven/ImportMavenDependencies.java @@ -36,6 +36,7 @@ import org.argeo.jcr.JcrUtils; import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; import org.argeo.slc.aether.AetherTemplate; +import org.argeo.slc.aether.ArtifactIdComparator; import org.argeo.slc.repo.ArtifactIndexer; import org.argeo.slc.repo.JarFileIndexer; import org.argeo.slc.repo.RepoConstants; @@ -55,20 +56,17 @@ public class ImportMavenDependencies implements Runnable { private AetherTemplate aetherTemplate; private String rootCoordinates = "org.argeo.dep:versions-all:pom:1.2.0"; private String distCoordinates = "org.argeo.tp:dist:pom:1.3.0"; + private String parentPomCoordinates = "org.argeo:parent:1.2.0"; private Set excludedArtifacts = new HashSet(); private Repository repository; private String workspace; - private String artifactBasePath = RepoConstants.ARTIFACTS_BASE_PATH; + private String artifactBasePath = RepoConstants.DEFAULT_ARTIFACTS_BASE_PATH; private ArtifactIndexer artifactIndexer = new ArtifactIndexer(); private JarFileIndexer jarFileIndexer = new JarFileIndexer(); - private Comparator artifactComparator = new Comparator() { - public int compare(Artifact o1, Artifact o2) { - return o1.getArtifactId().compareTo(o2.getArtifactId()); - } - }; + private Comparator artifactComparator = new ArtifactIdComparator(); public void run() { // resolve @@ -91,6 +89,8 @@ public class ImportMavenDependencies implements Runnable { node.remove(); } session.save(); + + // sync syncDistribution(session, artifacts); } catch (Exception e) { throw new SlcException("Cannot import distribution", e); @@ -113,7 +113,8 @@ public class ImportMavenDependencies implements Runnable { registeredArtifacts, pomArtifact); Artifact sdkArtifact = new DefaultArtifact(distCoordinates); String sdkPom = MavenConventionsUtils.artifactsAsDependencyPom( - sdkArtifact, registeredArtifacts); + sdkArtifact, registeredArtifacts, new DefaultArtifact( + parentPomCoordinates)); if (log.isDebugEnabled()) log.debug("Gathered " + registeredArtifacts.size() + " artifacts:\n" + sdkPom); @@ -186,8 +187,7 @@ public class ImportMavenDependencies implements Runnable { artifactComparator); Long begin = System.currentTimeMillis(); try { - JcrUtils.mkdirs(jcrSession, artifactBasePath, NodeType.NT_FOLDER, - NodeType.NT_FOLDER, false); + JcrUtils.mkfolders(jcrSession, artifactBasePath); artifacts: for (Artifact artifact : artifacts) { // skip excluded if (excludedArtifacts.contains(artifact.getGroupId() + ":" @@ -210,8 +210,7 @@ public class ImportMavenDependencies implements Runnable { .artifactParentPath(artifactBasePath, artifact); Node parentNode; if (!jcrSession.itemExists(parentPath)) - parentNode = JcrUtils.mkdirs(jcrSession, parentPath, - NodeType.NT_FOLDER, NodeType.NT_FOLDER, false); + parentNode = JcrUtils.mkfolders(jcrSession, parentPath); else parentNode = jcrSession.getNode(parentPath); @@ -263,7 +262,7 @@ public class ImportMavenDependencies implements Runnable { Artifact origSourceArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), "sources", artifact.getExtension(), artifact.getVersion()); - Artifact targetSourceArtifact = new DefaultArtifact( + Artifact newSourceArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId() + ".source", artifact.getExtension(), artifact.getVersion()); @@ -272,22 +271,22 @@ public class ImportMavenDependencies implements Runnable { .getResolvedFile(origSourceArtifact); } catch (Exception e) { // also try artifact following the conventions - origSourceArtifact = targetSourceArtifact; + origSourceArtifact = newSourceArtifact; origSourceFile = aetherTemplate .getResolvedFile(origSourceArtifact); } - String sourceParentPath = MavenConventionsUtils.artifactParentPath( - artifactBasePath, targetSourceArtifact); - Node sourceParentNode = JcrUtils.mkdirs(session, sourceParentPath, - NodeType.NT_FOLDER); + String newSourceParentPath = MavenConventionsUtils + .artifactParentPath(artifactBasePath, newSourceArtifact); + Node newSourceParentNode = JcrUtils.mkfolders(session, + newSourceParentPath); NameVersion bundleNameVersion = RepoUtils .readNameVersion(artifactFile); RepoUtils.packagesAsPdeSource(origSourceFile, bundleNameVersion, out); - String targetSourceFileName = MavenConventionsUtils - .artifactFileName(targetSourceArtifact); - JcrUtils.copyBytesAsFile(sourceParentNode, targetSourceFileName, + String newSourceFileName = MavenConventionsUtils + .artifactFileName(newSourceArtifact); + JcrUtils.copyBytesAsFile(newSourceParentNode, newSourceFileName, out.toByteArray()); } catch (Exception e) { log.error("Cannot add PDE source for " + artifact + ": " + e);