Created
December 17, 2013 01:52
-
-
Save lifuzu/7998628 to your computer and use it in GitHub Desktop.
Upload an existing collection of 3rd-party Jars to a Maven server in Gradle?
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
apply plugin:'java' | |
apply plugin:'maven' | |
import org.gradle.api.internal.artifacts.publish.DefaultPublishArtifact | |
version = "6.1.1" | |
group = "com.oahu" | |
ant.importBuild "$projectDir/tools/ant/package.xml" | |
// a list of the ant tasks that create a jar | |
// I assumed the following convention: | |
// ant task named "SampleAntJar-jar" creates the jar "build/SampleAntJar.jar" | |
def antJarTasks = ["SampleAntJar-jar", "SecondSampleAntJar-jar"] | |
artifacts{ | |
//for each ant task add a defaultpublishArtifact to the archives configuration | |
antJarTasks.each{ taskName -> | |
def artifactName = taskName - '-jar' | |
archives new DefaultPublishArtifact(artifactName, "jar", "jar", null, new | |
Date(), new File("$buildDir", "${artifactName}.jar")) | |
} | |
} | |
uploadArchives(){ | |
dependsOn: antJarTasks | |
repositories { | |
mavenDeployer { | |
repository(url: "file://{'/Users/Rene/.m2/repository/'}") | |
antJarTasks.each{ antJarTask -> | |
antJarName = antJarTask - "-jar" | |
addFilter(antJarName) {artifact, file -> | |
artifact.name == antJarName | |
} | |
pom(antJarName).artifactId = antJarName | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment