Skip to content

Commit

Permalink
[US642] Add gradle release and versioning plugin (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrdytkowski authored Feb 8, 2022
1 parent f690d44 commit ef90fbf
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 131 deletions.
26 changes: 25 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ pool:
vmImage: ubuntu-latest

steps:
- script: |
git checkout $(Build.SourceBranchName)
git config --global user.name "Azure DevOps"
displayName: "git config"
- task: MavenAuthenticate@0
displayName: 'authenticate maven'
inputs:
artifactsFeeds: bt
- task: Gradle@2
inputs:
workingDirectory: ''
Expand All @@ -20,4 +28,20 @@ steps:
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/TEST-*.xml'
tasks: 'build'
tasks: 'clean test'
- task: Gradle@2
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.8'
jdkArchitectureOption: 'x64'
tasks: 'release -Prelease.useAutomaticVersion=true'
- task: PublishPipelineArtifact@1
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
targetPath: $(System.DefaultWorkingDirectory)/build/libs/$(artifactName)
artifactName: artifact
displayName: "publish build artifact"
132 changes: 3 additions & 129 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ buildscript {

plugins {
id("net.ltgt.errorprone") version "0.8.1" apply false
id 'net.researchgate.release' version '2.8.1'
}

configure(allprojects) {
Expand All @@ -53,27 +54,13 @@ apply(from: "project.gradle");

group = "com.github.java-json-tools";

ext.forRelease = !version.endsWith("-SNAPSHOT");

/*
* Repositories to use
*/
repositories {
mavenCentral();
if (!forRelease) {
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
/* Allow staging references for last pre-release testing. */
if (project.properties.containsKey("sonatypeUsername")) {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
credentials {
username = project.properties["sonatypeUsername"]
password = project.properties["sonatypePassword"]
}
}
maven {
url "https://pkgs.dev.azure.com/Gravity9Solutions/BT/_packaging/bt/maven/v1"
}
}

Expand Down Expand Up @@ -117,15 +104,6 @@ allprojects {
}
}

/*
* Javadoc: we need to tell where the overview.html is, it will not pick it up
* automatically...
*/

//javadoc {
// options.overview = "src/main/java/overview.html";
//}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc";
from javadoc.destinationDir;
Expand All @@ -142,108 +120,4 @@ wrapper {
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
}

task pom {
doLast {
pom {}.writeTo("${projectDir}/pom.xml");
}
}

/*
* SIGNING
*/

project.ext {
scmUrl = sprintf("git@github.com:java-json-tools/%s.git", name);
projectURL = sprintf("https://github.com/java-json-tools/%s", name);
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
};

task checkSigningRequirements {
doLast {
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
def noDice = false;
requiredProperties.each {
if (project.properties[it] == null) {
noDice = true;
System.err.printf("property \"%s\" is not defined!\n", it);
}
}
if (noDice)
throw new IllegalStateException("missing required properties for " +
"upload");
}
}

uploadArchives {
dependsOn(checkSigningRequirements);
repositories {
mavenDeployer {
beforeDeployment {
MavenDeployment deployment -> signing.signPom(deployment);
}

repository(url: "${sonatypeStaging}") {
authentication(
userName: project.properties["sonatypeUsername"],
password: project.properties["sonatypePassword"]
);
}

snapshotRepository(url: "${sonatypeSnapshots}") {
authentication(
userName: project.properties["sonatypeUsername"],
password: project.properties["sonatypePassword"]
);
}
}
}
}

/*
* Configure pom.xml on install, uploadArchives
*/
[
install.repositories.mavenInstaller,
uploadArchives.repositories.mavenDeployer
]*.pom*.whenConfigured { pom ->
pom.project {
name "${project.name}";
packaging "jar";
description "${project.ext.description}";
url "${projectURL}";

scm {
url "${scmUrl}";
connection "${scmUrl}";
developerConnection "scm:git:${scmUrl}";
}

licenses {
license {
name "Lesser General Public License, version 3 or greater";
url "http://www.gnu.org/licenses/lgpl.html";
distribution "repo";
};
license {
name "Apache Software License, version 2.0";
url "http://www.apache.org/licenses/LICENSE-2.0";
distribution "repo";
}
}

developers {
developer {
id "huggsboson";
name "John Huffaker";
email "jhuffaker+java-json-tools@gmail.com";
}
}
}
}

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

2 changes: 1 addition & 1 deletion project.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Project-specific settings. Unfortunately we cannot put the name in there!
*/
group = "com.github.java-json-tools";
version = "2.0.0";
version = "2.0.0-SNAPSHOT";
sourceCompatibility = JavaVersion.VERSION_1_7;
targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility
project.ext.description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java, using extended TMF620 JsonPath syntax";
Expand Down

0 comments on commit ef90fbf

Please sign in to comment.