Skip to content

Instantly share code, notes, and snippets.

@mikeholler
Created February 3, 2014 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeholler/8793787 to your computer and use it in GitHub Desktop.
Save mikeholler/8793787 to your computer and use it in GitHub Desktop.
Publish binary, source, and javadoc jars to maven repository requiring username/password credentials.
apply plugin: 'java'
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
// Specifies a JAR that contains source code from the library.
from sourceSets.main.allJava
}
task fatJar(type: Jar, dependsOn: build) {
// Creates a JAR that contains all dependencies in addition to the library.
// from http://fw-geekycoder.blogspot.com/2011/11/how-to-create-jar-with-dependencies-in.html
from sourceSets.main.output
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest { attributes 'Main-Class': 'test.Main' }
}
task javadocJar(type: Jar, dependsOn: javadoc) {
// Specifies a JAR that contains Javadoc for the library.
from javadoc.destinationDir
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
artifact fatJar {
classifier "all"
}
}
}
repositories {
maven {
credentials {
username mavenUser
password mavenPass
}
url mavenVgbioUrl
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment