Skip to content

Commit

Permalink
WIP Publish to Central Repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
wiseman committed Jun 7, 2016
1 parent 32e4182 commit 7b4b5d1
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 14 deletions.
15 changes: 1 addition & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply from: 'maven-push.gradle'

repositories {
mavenCentral()
Expand Down Expand Up @@ -37,16 +37,3 @@ jacocoTestReport {
}

check.dependsOn jacocoTestReport

group = 'com.lemondronor'
version = '1.0.0'

publishing {
publications {
maven(MavenPublication) {
artifactId 'modesbeast'

from components.java
}
}
}
15 changes: 15 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
POM_NAME=modesbeast
POM_ARTIFACT_ID=modesbeast
VERSION_NAME=0.0.1-SNAPSHOT
GROUP=com.lemondronor
POM_DESCRIPTION=A library that does X, Y, and Z
POM_URL=https://github.com/wiseman/ProjectName
POM_SCM_URL=https://github.com/github_username/ProjectName
POM_SCM_CONNECTION=scm:git@github.com:github_username/ProjectName.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:github_username/ProjectName.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=wiseman
POM_DEVELOPER_NAME=John Wiseman
POM_PACKAGING=jar
92 changes: 92 additions & 0 deletions maven-push.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apply plugin: 'maven'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME

repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}

pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL

scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}

licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}

developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}

signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

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

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

artifacts {
archives javadocJar, sourcesJar
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':sample', ':library'

0 comments on commit 7b4b5d1

Please sign in to comment.