X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2Fmaven%2FImportMavenDependencies.java;h=bcb745e08acb95cc5cb6badf29209d970c4b7adf;hb=b91ff34d9c8c9f93f1f49f78b07ae626f0a99445;hp=3f001546558805a998ca442bb7118847008856ce;hpb=85f08be9b08c3938d25c46cae5b56dd0c4543cc7;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 3f0015465..bcb745e08 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 @@ -54,6 +54,7 @@ public class ImportMavenDependencies implements Runnable { private AetherTemplate aetherTemplate; private String rootCoordinates; + private String distCoordinates = "org.argeo.tp:dist:pom:1.3.0"; private Set excludedArtifacts = new HashSet(); private Repository repository; @@ -74,6 +75,10 @@ public class ImportMavenDependencies implements Runnable { Set artifacts = resolveDistribution(); // sync + sync(artifacts); + } + + void sync(Set artifacts) { Session session = null; try { session = JcrUtils.loginOrCreateWorkspace(repository, workspace); @@ -93,7 +98,11 @@ public class ImportMavenDependencies implements Runnable { } } - private Set resolveDistribution() { + /** + * Generate a POM with all the artifacts declared in root coordinates as + * dependencies AND in dependency management. + */ + void createDistPom() { try { Artifact pomArtifact = new DefaultArtifact(rootCoordinates); @@ -101,42 +110,57 @@ public class ImportMavenDependencies implements Runnable { artifactComparator); MavenConventionsUtils.gatherPomDependencies(aetherTemplate, registeredArtifacts, pomArtifact); - Artifact sdkArtifact = new DefaultArtifact( - "org.argeo.tp:dist:pom:1.3.0"); + Artifact sdkArtifact = new DefaultArtifact(distCoordinates); String sdkPom = MavenConventionsUtils.artifactsAsDependencyPom( sdkArtifact, registeredArtifacts); if (log.isDebugEnabled()) log.debug("Gathered " + registeredArtifacts.size() + " artifacts:\n" + sdkPom); - // Resolve and add non-optional dependencies + } catch (Exception e) { + throw new SlcException("Cannot resolve distribution", e); + } + } + + /** Returns all transitive dependencies of dist POM */ + private Set resolveDistribution() { + try { + Artifact distArtifact = new DefaultArtifact(distCoordinates); Set artifacts = new TreeSet(artifactComparator); - /* - for (Artifact artifact : registeredArtifacts) { - try { - Boolean wasAdded = addArtifact(artifacts, artifact); - if (wasAdded) { - DependencyNode node = aetherTemplate - .resolveDependencies(artifact); - addDependencies(artifacts, node, null); - } - } catch (Exception e) { - log.error("Could not resolve dependencies of " + artifact - + ": " + e.getCause().getMessage()); - } - } + DependencyNode node = aetherTemplate + .resolveDependencies(distArtifact); + addDependencies(artifacts, node, null); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("Resolved " + artifacts.size() + " artifacts"); - // distribution descriptor - // Properties distributionDescriptor = - // generateDistributionDescriptor(artifacts); - // ByteArrayOutputStream out = new ByteArrayOutputStream(); - // distributionDescriptor.store(out, ""); - // log.debug(new String(out.toByteArray())); - // out.close(); -*/ +// Properties distributionDescriptor = generateDistributionDescriptor(artifacts); +// ByteArrayOutputStream out = new ByteArrayOutputStream(); +// distributionDescriptor.store(out, ""); +// log.debug(new String(out.toByteArray())); +// out.close(); + } + + /* + * for (Artifact artifact : registeredArtifacts) { try { Boolean + * wasAdded = addArtifact(artifacts, artifact); if (wasAdded) { + * DependencyNode node = aetherTemplate + * .resolveDependencies(artifact); addDependencies(artifacts, node, + * null); } } catch (Exception e) { + * log.error("Could not resolve dependencies of " + artifact + ": " + * + e.getCause().getMessage()); } + * + * } + * + * if (log.isDebugEnabled()) log.debug("Resolved " + + * artifacts.size() + " artifacts"); + * + * // distribution descriptor // Properties distributionDescriptor = + * // generateDistributionDescriptor(artifacts); // + * ByteArrayOutputStream out = new ByteArrayOutputStream(); // + * distributionDescriptor.store(out, ""); // log.debug(new + * String(out.toByteArray())); // out.close(); + */ return artifacts; } catch (Exception e) { throw new SlcException("Cannot resolve distribution", e); @@ -192,7 +216,7 @@ public class ImportMavenDependencies implements Runnable { jarFileIndexer.index(fileNode); jcrSession.save(); - addPdeSource(jcrSession, artifact, jarFile, artifacts); + addPdeSource(jcrSession, artifact, jarFile, artifactsWithoutSources); jcrSession.save(); if (log.isDebugEnabled()) @@ -267,8 +291,8 @@ public class ImportMavenDependencies implements Runnable { /** Recursively adds non optional dependencies */ private void addDependencies(Set artifacts, DependencyNode node, String ancestors) { - if (artifacts.contains(node.getDependency().getArtifact())) - return; +// if (artifacts.contains(node.getDependency().getArtifact())) +// return; String currentArtifactId = node.getDependency().getArtifact() .getArtifactId(); if (log.isDebugEnabled()) {