Skip to content

Instantly share code, notes, and snippets.

@ae6rt
Created August 15, 2013 14:26
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 ae6rt/6241247 to your computer and use it in GitHub Desktop.
Save ae6rt/6241247 to your computer and use it in GitHub Desktop.
Gradle build config for publishing artifact with source code to a Maven repository.
apply plugin: 'java'
apply plugin: 'maven-publish'
group = "org.petrovic"
version = "0.2"
ext.versions = [
logback: "1.0.13",
junit: "4.11",
hamcrest: "1.3"
]
repositories {
mavenCentral()
}
dependencies {
compile group: "ch.qos.logback", name: "logback-classic", version: versions.logback
testCompile group: "junit", name: "junit", version: versions.junit
testCompile group: "org.hamcrest", name: "hamcrest-all", version: versions.hamcrest
}
task wrapper(type: Wrapper) {
gradleVersion = '1.7'
}
test {
testLogging.showStandardStreams = true
}
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
tasks.withType(Test) {
systemProperties = System.getProperties()
testLogging.showStandardStreams = true
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "source"
}
}
}
repositories {
maven {
url "https://mavenrepo.example.com"
credentials {
username = "x"
password = "x"
}
}
}
}
@agibalov
Copy link

publications {
    mavenJava(MavenPublication) {
        from components.java
        artifact sourceJar {
            classifier "source"

classifier "source" should be classifier "sources".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment