diff --git a/.gitignore b/.gitignore index 67a729b..8a3e61d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,7 @@ bin/ libs/ build/ .gradle -.gradletasknamecache \ No newline at end of file +.gradletasknamecache +/monkey-netty/publishing/publishing.properties +/monkey-netty/publishing/*.asc +/monkey-netty/publishing/*.gpg diff --git a/build.gradle b/build.gradle index 42e720f..e8bf7fd 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,7 @@ +plugins { + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' +} + allprojects { version = '0.1.2-SNAPSHOT' group = "io.tlf.monkeynetty" diff --git a/monkey-netty/build.gradle b/monkey-netty/build.gradle index f250fd5..fa445e4 100644 --- a/monkey-netty/build.gradle +++ b/monkey-netty/build.gradle @@ -3,6 +3,8 @@ plugins { id 'maven-publish' } +apply from: './publishing/publishing.gradle' + java { withJavadocJar() withSourcesJar() diff --git a/monkey-netty/publishing/publishing.gradle b/monkey-netty/publishing/publishing.gradle new file mode 100644 index 0000000..6a72f4f --- /dev/null +++ b/monkey-netty/publishing/publishing.gradle @@ -0,0 +1,107 @@ +// Create variables with empty default values + +apply plugin: 'maven-publish' +apply plugin: 'signing' + +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.secretKeyRingFile"] = '' + +ext { + PUBLISH_GROUP_ID = group + PUBLISH_VERSION = version + PUBLISH_ARTIFACT_ID = name +} + +File secretPropsFile = project.rootProject.file('publishing/publishing.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } +} + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives javadocJar, sourcesJar +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + groupId PUBLISH_GROUP_ID + artifactId PUBLISH_ARTIFACT_ID + version PUBLISH_VERSION + + from components.java + + artifact sourcesJar + artifact javadocJar + + pom { + name = PUBLISH_ARTIFACT_ID + description = 'A implementation of a server-client communication system for jMonkeyEngine using Netty.IO that utilizes both TCP and UDP communication.' + url = 'https://github.com/tlf30/monkey-netty' + licenses { + license { + name = 'MIT' + url = 'https://github.com/tlf30/monkey-netty/blob/master/LICENSE' + } + } + developers { + developer { + id = 'tlf30' + name = 'Trevor Flynn' + email = 'trevorflynn@liquidcrystalstudios.com' + } + } + + scm { + connection = 'scm:git:github.com/tlf30/monkey-netty.git' + developerConnection = 'scm:git:ssh://github.com/tlf30/monkey-netty.git' + url = 'https://github.com/tlf30/monkey-netty/tree/master' + } + } + } + } + } +} + +signing { + sign publishing.publications +} +