Created
April 8, 2015 15:35
-
-
Save mizdebsk/2e022dd00f21b349ce4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path where to copy artifacts, you can change it to ~/.m2/repository | |
repo_path = "/tmp/myrepo" | |
# List of artifacts to copy | |
coords = ["junit:junit:4.11", | |
"org.sonatype.sisu:sisu-guice::no_aop:3.2.5", | |
"org.apache.commons:commons-lang:1.2.3"] | |
import os | |
import re | |
import shutil | |
from javapackages.xmvn.xmvn_resolve import XMvnResolve, ResolutionRequest | |
from javapackages.maven.artifact import Artifact | |
# Create artifacts from specified coordinates | |
artifacts = [Artifact.from_mvn_str(coord) for coord in coords] | |
# Also resolve POM files for all artifacts | |
artifacts.extend([Artifact(a.groupId, a.artifactId, "pom", "", a.version) for a in artifacts]) | |
# Resolve all artifacts | |
results = XMvnResolve.process_raw_request([ResolutionRequest(a.groupId, a.artifactId, a.extension, a.classifier, a.version) for a in artifacts]) | |
# Copy resolved artifact files to destination repo | |
for a, r in zip(artifacts, results): | |
dir = "%s/%s/%s" % (repo_path, a.groupId.replace(".", "/"), a.version) | |
if not os.path.isdir(dir): | |
os.makedirs(dir) | |
path = "%s/%s-%s%s.%s" % (dir, a.artifactId, a.version, re.sub("^(.)", "-\g<1>", a.classifier), a.extension) | |
shutil.copyfile(r.artifactPath, path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment