From ba46face1d60d2681d2660c227dfa11545add3b4 Mon Sep 17 00:00:00 2001 From: shyamz-22 Date: Sat, 16 Dec 2017 22:57:20 +0100 Subject: [PATCH] Add maven central publishing data --- build.gradle | 18 +++++++++++++- gradle.properties | 18 ++++++++++++++ publishToMaven.gradle | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 gradle.properties create mode 100644 publishToMaven.gradle diff --git a/build.gradle b/build.gradle index 376c303..5a2fc8d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ setGroup("io.github.shyamz-22") jar { baseName = 'conditional' - version = '0.0.1-SNAPSHOT' + version = VERSION_NAME } @@ -42,3 +42,19 @@ task wrapper(type: Wrapper) { bootRepackage { enabled = false } + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives javadocJar, sourcesJar +} + +apply from: 'publishToMaven.gradle' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..197bc39 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +VERSION_NAME=0.0.1-SNAPSHOT +ARTIFACT_ID=conditional +GROUP=io.github.shyamz-22 + +POM_NAME=Conditional On Profiles +POM_PACKAGING=jar +POM_DESCRIPTION=Create a Spring Bean only if All profiles are active. +POM_URL=https://github.com/shyamz-22/conditional-profiles.git +POM_SCM_URL=https://github.com/shyamz-22/conditional-profiles.git +POM_SCM_CONNECTION=git@github.com:shyamz-22/conditional-profiles.git +POM_SCM_DEV_CONNECTION=git@github.com:shyamz-22/conditional-profiles.git +POM_LICENCE_NAME=MIT License +POM_LICENCE_URL=https://github.com/shyamz-22/conditional-profiles/blob/master/LICENSE +POM_DEVELOPER_ID=shyamz-22 +POM_DEVELOPER_NAME=Syamala Umamaheswaran + +RELEASE_REPOSITORY_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2 +SNAPSHOT_REPOSITORY_URL=https://oss.sonatype.org/content/repositories/snapshots \ No newline at end of file diff --git a/publishToMaven.gradle b/publishToMaven.gradle new file mode 100644 index 0000000..cffdabd --- /dev/null +++ b/publishToMaven.gradle @@ -0,0 +1,57 @@ +apply plugin: 'maven' +apply plugin: 'signing' + +ext.isReleaseVersion = !version.endsWith("SNAPSHOT") + +signing { + required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") } + sign configurations.archives +} + +uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.groupId = GROUP + pom.artifactId = ARTIFACT_ID + pom.version = VERSION_NAME + + pom.project { + name POM_NAME + packaging POM_PACKAGING + // optionally artifactId can be defined here + description POM_DESCRIPTION + url POM_URL + + scm { + connection POM_SCM_CONNECTION + developerConnection POM_SCM_DEV_CONNECTION + url POM_SCM_URL + } + + licenses { + license { + name POM_LICENCE_NAME + url POM_LICENCE_URL + } + } + + developers { + developer { + id POM_DEVELOPER_ID + name POM_DEVELOPER_NAME + } + } + } + } + } +} \ No newline at end of file