tokuhirom's blog

gradle で maven central にリリースできた。

http://tagomoris.hatenablog.com/entries/2016/02/16

こちらを参考にしてやったら簡単にできた。 tagomoirs++

// releng: gradle clean && gradle uploadArchives -Prelease

group 'me.geso'
version '1.0.0'

apply plugin: 'java'
apply plugin: "maven"
apply plugin: "signing"

sourceCompatibility = 1.8

//set build variables based on build type (release, continuous integration, development)
def isDevBuild
def isCiBuild
def isReleaseBuild
def sonatypeRepositoryUrl
if (hasProperty("release")) {
    isReleaseBuild = true
    sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else if (hasProperty("ci")) {
    isCiBuild = true
    version += "-SNAPSHOT"
    sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
} else {
    isDevBuild = true
    version += "-SNAPSHOT"
}

repositories {
    mavenCentral()
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from "${buildDir}/javadoc"
}

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives javadocJar, sourcesJar
}

signing {
    required { isReleaseBuild }
    sign configurations.archives
}

uploadArchives {
    repositories {
        if (isDevBuild) {
            mavenLocal()
        }
        else {
            mavenDeployer {
                if(isReleaseBuild) {
                    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
                }

                repository(url: sonatypeRepositoryUrl) {
                    authentication(userName: sonatypeUsername, password: sonatypePassword)
                }

                pom.project {
                    name 'paranoid_dns_resolver'
                    packaging 'jar'
                    description 'Paranoid DNS Resolver'
                    url 'https://github.com/tokuhirom/paranoid_dns_resolver'

                    scm {
                        url "scm:git@github.com:tokuhirom/paranoid_dns_resolver.git"
                        connection "scm:git@github.com:tokuhirom/paranoid_dns_resolver.git"
                        developerConnection "scm:git@github.com:tokuhirom/paranoid_dns_resolver.git"
                    }
                    licenses {
                        license {
                            name 'MIT'
                            url 'https://opensource.org/licenses/MIT'
                        }
                    }
                    developers {
                        developer {
                            id 'tokuhirom'
                            name 'Tokuhiro Matsuno'
                            email 'tokuhirom@gmail.com'
                        }
                    }
                }
            }
        }
    }
}

dependencies {
    compile 'org.apache.httpcomponents:httpclient:4.5.2'
    compile 'com.github.tomakehurst:wiremock:1.58'
    compile 'org.assertj:assertj-core:3.3.0'
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}
Created: 2016-05-02 14:24:54 +0900
Updated: 2016-05-02 14:24:54 +0900