Skip to content

Commit

Permalink
Add better GAV matching from config file
Browse files Browse the repository at this point in the history
Don't attempt to download source jars for pom artifacts
  • Loading branch information
pgier committed Feb 5, 2013
1 parent d6e5675 commit 38db242
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions maven_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def __init__(self, gav):
else:
print 'Invalid GAV string: ' + gav

def getArtifactType(self):
return self.artifactType

def getDirPath(self):
"""Get the relative repository path to the artifact"""
relativePath = self.groupId.replace('.', '/') + '/'
Expand Down
23 changes: 13 additions & 10 deletions maven_repo_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ def downloadArtifact(remoteRepoUrl, localRepoDir, artifact):
download(artifactPomUrl, artifactPomLocalPath)

# Download sources
artifactSourcesUrl = remoteRepoUrl + '/' + artifact.getSourcesFilepath()
artifactSourcesLocalPath = os.path.join(localRepoDir, artifact.getSourcesFilepath())
if not os.path.exists(artifactSourcesLocalPath):
download(artifactSourcesUrl, artifactSourcesLocalPath)
if artifact.getArtifactType() != 'pom':
artifactSourcesUrl = remoteRepoUrl + '/' + artifact.getSourcesFilepath()
artifactSourcesLocalPath = os.path.join(localRepoDir, artifact.getSourcesFilepath())
if not os.path.exists(artifactSourcesLocalPath):
download(artifactSourcesUrl, artifactSourcesLocalPath)


def copyArtifact(remoteRepoPath, localRepoDir, artifact):
"""Download artifact from a remote repository along with pom and source jar"""
Expand All @@ -93,18 +95,19 @@ def copyArtifact(remoteRepoPath, localRepoDir, artifact):
shutil.copyfile(artifactPomPath, artifactPomLocalPath)

# Download sources
artifactSourcesPath = os.path.join(remoteRepoPath, artifact.getSourcesFilepath())
artifactSourcesLocalPath = os.path.join(localRepoDir, artifact.getSourcesFilepath())
if os.path.exists(artifactSourcesPath) and not os.path.exists(artifactSourcesLocalPath):
print('Copying file: ' + artifactSourcesPath)
shutil.copyfile(artifactSourcesPath, artifactSourcesLocalPath)
if artifact.getArtifactType() != 'pom':
artifactSourcesPath = os.path.join(remoteRepoPath, artifact.getSourcesFilepath())
artifactSourcesLocalPath = os.path.join(localRepoDir, artifact.getSourcesFilepath())
if os.path.exists(artifactSourcesPath) and not os.path.exists(artifactSourcesLocalPath):
print('Copying file: ' + artifactSourcesPath)
shutil.copyfile(artifactSourcesPath, artifactSourcesLocalPath)


def depListToArtifactList(depList):
"""Convert the maven GAV to a URL relative path"""
regexComment = re.compile('#.*$')
#regexLog = re.compile('^\[\w*\]')
regexGAV = re.compile('([\w\-.]*:){4}[\w]*\S')
regexGAV = re.compile('(([\w\-.]+:){3}[\w\-.]+)(:[\w]*\S)?')
artifactList = []
for nextLine in depList:
nextLine = regexComment.sub('', nextLine)
Expand Down

0 comments on commit 38db242

Please sign in to comment.