Last active
May 22, 2017 03:09
-
-
Save namutaka/bbefbff81793976ec17829bc736e833c to your computer and use it in GitHub Desktop.
ivyのcacheをlocalに変換してリポジトリとして使う
This file contains hidden or 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
#!/usr/bin/python | |
# -*- conding: utf-8 -*- | |
# | |
# copy ivy cache to local | |
# | |
import sys | |
import os | |
import re | |
import glob | |
import shutil | |
IVY_PATTERN = re.compile('.*/(?P<organization>[^/]+)/(?P<module>[^/]+)/ivy-(?P<revision>.+)\.xml') | |
FILE_PATTERN = re.compile('.*/(?P<organization>[^/]+)/(?P<module>[^/]+)/(?P<type>[^/]+)s/(?P<artifact>.+)-(?P<revision>.+)\.(?P<ext>.+)') | |
_, src_dir, dest_dir = sys.argv | |
ivyfiles = glob.glob(src_dir + '/*/*/ivy-*.xml') | |
for ivy in ivyfiles: | |
m = IVY_PATTERN.match(ivy) | |
organization, module, revision = m.group('organization', 'module', 'revision') | |
dest_ivy_dir = '/'.join([dest_dir, organization, module, revision, 'ivys']) | |
if not os.path.exists(dest_ivy_dir): | |
os.makedirs(dest_ivy_dir) | |
shutil.copy(ivy, dest_ivy_dir + '/ivy.xml') | |
print ivy + " -> " + dest_ivy_dir + '/ivy.xml' | |
files = glob.glob('/'.join([src_dir, organization, module, '*s', '*-' + revision + '.*'])) | |
for file in files: | |
fm = FILE_PATTERN.match(file) | |
type, artifact, ext = fm.group('type', 'artifact', 'ext') | |
dest_file_dir = '/'.join([dest_dir, organization, module, revision, type + 's']) | |
if not os.path.exists(dest_file_dir): | |
os.makedirs(dest_file_dir) | |
shutil.copy(file, dest_file_dir + '/' + artifact + '.' + ext) | |
print file + " -> " + dest_file_dir + '/' + artifact + '.' + ext |
This file contains hidden or 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
[repositories] | |
local | |
ivy-local: file://${user.dir}/ivy-local, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext] | |
maven-local | |
maven-central |
This file contains hidden or 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
sbt \ | |
-Dsbt.override.build.repos=true \ | |
-Dsbt.repository.config=sbtrepositories \ | |
-Dsbt.ivy.home=ivy2 \ | |
update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment