Skip to content

[US642] Add gradle release and versioning plugin #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be 1.11

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceCompatibility = JavaVersion.VERSION_1_7;

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why azure used 1.8 automatically, but it works, why would you use 1.11?

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("[email protected]: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 "[email protected]";
}
}
}
}

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