Skip to content
Browse files

initial commit

  • Loading branch information...
1 parent 9753106 commit 1e836603a03bfa5bc322e28baa790ccf741e7fd5 rpunnoose committed May 2, 2012
Showing with 166 additions and 1 deletion.
  1. +8 −1 README.md
  2. +62 −0 examples/openrdf-sesame-2.6.4.txt
  3. +96 −0 loaddir-maven.groovy
View
9 README.md
@@ -1,4 +1,11 @@
loaddir-maven
=============
-Load a flat lib directory to maven format based on a properties list mapping artifact names to the full maven url
+Load a flat lib directory to maven format based on a properties list mapping artifact names to the full maven url
+
+Example
+============
+
+groovy DeployDirMvnArtifacts.groovy /temp/mvnArtifacts.txt Downloads/openrdf-sesame-2.6.4/lib/ /temp/mvnout
+
+This will load the /temp/mvnArtifacts.txt as the properties file, reading the libraries from Downloads/openrdf-sesame-2.6.4/lib, and output the maven directory structure at /temp/mvnout
View
62 examples/openrdf-sesame-2.6.4.txt
@@ -0,0 +1,62 @@
+aopalliance-1.0 = mvn:aopalliance/aopalliance/1.0
+asm-3.1 = mvn:asm/asm/3.1
+cglib-2.2 = mvn:cglib/cglib/2.2
+commons-cli-1.2 = mvn:commons-cli/commons-cli/1.2
+commons-codec-1.4 = mvn:commons-codec/commons-codec/1.4
+commons-dbcp-1.3 = mvn:commons-dbcp/commons-dbcp/1.3
+commons-httpclient-3.1 = mvn:commons-httpclient/commons-httpclient/3.1
+commons-pool-1.5.4 = mvn:commons-pool/commons-pool/1.5.4
+jcl-over-slf4j-1.6.1 = mvn:org.slf4j/jcl-over-slf4j/1.6.1
+jstl-1.1.2 = mvn:javax.servlet/jstl/1.1.2
+logback-classic-0.9.28 = mvn:ch.qos.logback/logback-classic/0.9.28
+logback-core-0.9.28 = mvn:ch.qos.logback/logback-core/0.9.28
+opencsv-2.0 = mvn:net.sf.opencsv/opencsv/2.0
+sesame-config-2.6.4 = mvn:org.openrdf.sesame/sesame-config/2.6.4
+sesame-console-2.6.4 = mvn:org.openrdf.sesame/sesame-console/2.6.4
+sesame-http-client-2.6.4 = mvn:org.openrdf.sesame/sesame-http-client/2.6.4
+sesame-http-protocol-2.6.4 = mvn:org.openrdf.sesame/sesame-http-protocol/2.6.4
+sesame-http-server-spring-2.6.4 = mvn:org.openrdf.sesame/sesame-http-server-spring/2.6.4
+sesame-model-2.6.4 = mvn:org.openrdf.sesame/sesame-model/2.6.4
+sesame-query-2.6.4 = mvn:org.openrdf.sesame/sesame-query/2.6.4
+sesame-queryalgebra-evaluation-2.6.4 = mvn:org.openrdf.sesame/sesame-queryalgebra-evaluation/2.6.4
+sesame-queryalgebra-model-2.6.4 = mvn:org.openrdf.sesame/sesame-queryalgebra-model/2.6.4
+sesame-queryparser-api-2.6.4 = mvn:org.openrdf.sesame/sesame-queryparser-api/2.6.4
+sesame-queryparser-serql-2.6.4 = mvn:org.openrdf.sesame/sesame-queryparser-serql/2.6.4
+sesame-queryparser-sparql-2.6.4 = mvn:org.openrdf.sesame/sesame-queryparser-sparql/2.6.4
+sesame-queryresultio-api-2.6.4 = mvn:org.openrdf.sesame/sesame-queryresultio-api/2.6.4
+sesame-queryresultio-binary-2.6.4 = mvn:org.openrdf.sesame/sesame-queryresultio-binary/2.6.4
+sesame-queryresultio-sparqljson-2.6.4 = mvn:org.openrdf.sesame/sesame-queryresultio-sparqljson/2.6.4
+sesame-queryresultio-sparqlxml-2.6.4 = mvn:org.openrdf.sesame/sesame-queryresultio-sparqlxml/2.6.4
+sesame-queryresultio-text-2.6.4 = mvn:org.openrdf.sesame/sesame-queryresultio-text/2.6.4
+sesame-repository-api-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-api/2.6.4
+sesame-repository-contextaware-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-contextaware/2.6.4
+sesame-repository-dataset-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-dataset/2.6.4
+sesame-repository-event-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-event/2.6.4
+sesame-repository-http-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-http/2.6.4
+sesame-repository-manager-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-manager/2.6.4
+sesame-repository-sail-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-sail/2.6.4
+sesame-repository-sparql-2.6.4 = mvn:org.openrdf.sesame/sesame-repository-sparql/2.6.4
+sesame-rio-api-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-api/2.6.4
+sesame-rio-binary-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-binary/2.6.4
+sesame-rio-n3-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-n3/2.6.4
+sesame-rio-ntriples-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-ntriples/2.6.4
+sesame-rio-rdfxml-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-rdfxml/2.6.4
+sesame-rio-trig-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-trig/2.6.4
+sesame-rio-trix-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-trix/2.6.4
+sesame-rio-turtle-2.6.4 = mvn:org.openrdf.sesame/sesame-rio-turtle/2.6.4
+sesame-runtime-2.6.4 = mvn:org.openrdf.sesame/sesame-runtime/2.6.4
+sesame-sail-api-2.6.4 = mvn:org.openrdf.sesame/sesame-sail-api/2.6.4
+sesame-sail-inferencer-2.6.4 = mvn:org.openrdf.sesame/sesame-sail-inferencer/2.6.4
+sesame-sail-memory-2.6.4 = mvn:org.openrdf.sesame/sesame-sail-memory/2.6.4
+sesame-sail-nativerdf-2.6.4 = mvn:org.openrdf.sesame/sesame-sail-nativerdf/2.6.4
+sesame-sail-rdbms-2.6.4 = mvn:org.openrdf.sesame/sesame-sail-rdbms/2.6.4
+sesame-util-2.6.4 = mvn:org.openrdf.sesame/sesame-util/2.6.4
+slf4j-api-1.6.1 = mvn:org.slf4j/slf4j-api/1.6.1
+spring-aop-2.5.6 = mvn:org.springframework/spring-aop/2.5.6
+spring-beans-2.5.6 = mvn:org.springframework/spring-beans/2.5.6
+spring-context-2.5.6 = mvn:org.springframework/spring-context/2.5.6
+spring-context-support-2.5.6 = mvn:org.springframework/spring-context-support/2.5.6
+spring-core-2.5.6 = mvn:org.springframework/spring-core/2.5.6
+spring-web-2.5.6 = mvn:org.springframework/spring-web/2.5.6
+spring-webmvc-2.5.6 = mvn:org.springframework/spring-webmvc/2.5.6
+standard-1.1.2 = mvn:taglibs/standard/1.1.2
View
96 loaddir-maven.groovy
@@ -0,0 +1,96 @@
+import com.google.common.io.Files;
+
+@Grab(group='com.google.guava', module='guava', version='11.0.1')
+class LoadDirMvnOut {
+
+ def artifactsList
+ def artifactsDir
+ def outputMavenDir
+ def props = new Properties()
+
+ def init() {
+ //assertions
+ assert artifactsList != null
+ assert artifactsDir != null
+ assert outputMavenDir != null
+
+ //load artifacts list
+ props.load(new FileInputStream(artifactsList))
+
+ //list through libraries
+ def adir = new File(artifactsDir)
+ def outdir = new File(outputMavenDir)
+ assert adir.exists()
+ assert adir.isDirectory()
+
+ adir.listFiles().each { f ->
+ if(!f.isDirectory()) { //no subdir recursion
+ def fname = f.name
+ def versionSplitIndex = fname.lastIndexOf(".")
+ if(versionSplitIndex != -1) {
+ def artifactId = fname.substring(0, versionSplitIndex)
+ def fullMvnUrl = props.getProperty(artifactId)
+ if(fullMvnUrl == null) {
+ println "WARNING: ${artifactId} not found in the artifact list"
+ return;
+ }
+
+ def outFile = new File(translateFromMaven(fullMvnUrl))
+ Files.createParentDirs(outFile)
+ Files.copy(f, outFile)
+ } else {
+ println "WARNING: ${fname} is not in the correct format: artifactId-version.jar"
+ return;
+ }
+ }
+ }
+
+ }
+
+ def translateFromMaven(String uri) {
+ if (uri.startsWith("mvn:")) {
+ String[] parts = uri.substring("mvn:".length()).split("/");
+ String groupId = parts[0];
+ String artifactId = parts[1];
+ String version = null;
+ String classifier = null;
+ String type = "jar";
+ if (parts.length > 2) {
+ version = parts[2];
+ if (parts.length > 3) {
+ type = parts[3];
+ if (parts.length > 4) {
+ classifier = parts[4];
+ }
+ }
+ }
+
+ String dir = groupId.replace('.', '/') + "/" + artifactId + "/" + version + "/";
+ String name = artifactId + "-" + version + (classifier != null ? "-" + classifier : "") + "." + type;
+
+ return outputMavenDir + "/" + dir + name;
+ }
+ if (System.getProperty("os.name").startsWith("Windows")
+ && uri.startsWith("file:")) {
+ String baseDir = uri.substring(5).replace('\\', '/').replaceAll(
+ " ", "%20");
+ String result = baseDir;
+ if (baseDir.indexOf(":") > 0) {
+ result = "file:///" + baseDir;
+ }
+ return result;
+ }
+ return uri;
+ }
+
+}
+
+assert args.length == 3 : "Usage: groovy DeployDirMvnArtifacts <maven artifacts list> <input lib dir> <output maven dir>"
+
+def artifactsList = args[0]
+def artifactsDir = args[1]
+def outputMavenDir = args[2]
+
+def readDir = new LoadDirMvnOut(artifactsList: artifactsList, artifactsDir: artifactsDir, outputMavenDir: outputMavenDir)
+readDir.init()
+

0 comments on commit 1e83660

Please sign in to comment.
Something went wrong with that request. Please try again.