.getLog(ImportMavenDependencies.class);
private AetherTemplate aetherTemplate;
- private String rootCoordinates;
+ private String rootCoordinates = "org.argeo.dep:versions-all:pom:1.2.0";
private String distCoordinates = "org.argeo.tp:dist:pom:1.3.0";
private Set<String> excludedArtifacts = new HashSet<String>();
NodeIterator nit = session.getNode(artifactBasePath).getNodes();
while (nit.hasNext()) {
Node node = nit.nextNode();
- if (node.isNodeType(NodeType.NT_FOLDER))
+ if (node.isNodeType(NodeType.NT_FOLDER)
+ || node.isNodeType(NodeType.NT_UNSTRUCTURED))
node.remove();
}
session.save();
+
+ // sync
syncDistribution(session, artifacts);
} catch (Exception e) {
throw new SlcException("Cannot import distribution", e);
if (log.isDebugEnabled()) {
log.debug("Resolved " + artifacts.size() + " artifacts");
-// 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();
}
/*
return distributionDescriptor;
}
- private void syncDistribution(Session jcrSession, Set<Artifact> artifacts) {
+ /** Write artifacts to the target workspace, skipping excluded ones */
+ protected void syncDistribution(Session jcrSession, Set<Artifact> artifacts) {
Set<Artifact> artifactsWithoutSources = new TreeSet<Artifact>(
artifactComparator);
Long begin = System.currentTimeMillis();
try {
- JcrUtils.mkdirs(jcrSession, artifactBasePath);
+ JcrUtils.mkfolders(jcrSession, artifactBasePath);
artifacts: for (Artifact artifact : artifacts) {
+ // skip excluded
+ if (excludedArtifacts.contains(artifact.getGroupId() + ":"
+ + artifact.getArtifactId())) {
+ if (log.isDebugEnabled())
+ log.debug("Exclude " + artifact);
+ continue artifacts;
+ }
+
File jarFile = MavenConventionsUtils.artifactToFile(artifact);
if (!jarFile.exists()) {
log.warn("Generated file " + jarFile + " for " + artifact
.artifactParentPath(artifactBasePath, artifact);
Node parentNode;
if (!jcrSession.itemExists(parentPath))
- parentNode = JcrUtils.mkdirs(jcrSession, parentPath,
- NodeType.NT_FOLDER);
+ parentNode = JcrUtils.mkfolders(jcrSession, parentPath);
else
parentNode = jcrSession.getNode(parentPath);
jarFileIndexer.index(fileNode);
jcrSession.save();
- addPdeSource(jcrSession, artifact, jarFile, artifactsWithoutSources);
+ addPdeSource(jcrSession, artifact, jarFile,
+ artifactsWithoutSources);
jcrSession.save();
if (log.isDebugEnabled())
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());
.getResolvedFile(origSourceArtifact);
} catch (Exception e) {
// also try artifact following the conventions
- origSourceArtifact = targetSourceArtifact;
+ origSourceArtifact = newSourceArtifact;
origSourceFile = aetherTemplate
.getResolvedFile(origSourceArtifact);
}
- String parentPath = MavenConventionsUtils.artifactParentPath(
- artifactBasePath, artifact);
- Node parentNode = JcrUtils.mkdirs(session, parentPath,
- 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(parentNode, targetSourceFileName,
+ String newSourceFileName = MavenConventionsUtils
+ .artifactFileName(newSourceArtifact);
+ JcrUtils.copyBytesAsFile(newSourceParentNode, newSourceFileName,
out.toByteArray());
} catch (Exception e) {
log.error("Cannot add PDE source for " + artifact + ": " + e);
/** Recursively adds non optional dependencies */
private void addDependencies(Set<Artifact> 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()) {
this.workspace = workspace;
}
+ public void setDistCoordinates(String distCoordinates) {
+ this.distCoordinates = distCoordinates;
+ }
+
+ public void setArtifactBasePath(String artifactBasePath) {
+ this.artifactBasePath = artifactBasePath;
+ }
+
}