diff --git a/DEVELOPERS.md b/DEVELOPERS.md index deca81612f..9dcfd4e13a 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -1,28 +1,29 @@ ## Developer instructions ### Testing a release locally -Run nexus locally (assuming you have docker running locally): +Run artifactory locally (assuming you have docker running locally): ```bash -docker run -d -p 8081:8081 --name nexus sonatype/nexus +docker run -p 8080:8080 mattgruter/artifactory ``` -Configure the `distributionManagement` section in the root `pom.xml` to point to the repo on localhost. +Configure the `contextUrl` section in `publish.gradle` to point to `http://localhost:8080/artifactory`. -Add/update your `~/.m2/settings.xml` with the following config block: +Add/update your `~/.gradle/gradle.properties` with the following config block: -```xml - - - - nexus-local - admin - admin123 - - - +```properties +bintrayUser=admin +bintrayApiKey=password ``` +Upload artifacts to the local artifactory: + +```bash +./gradlew artifactoryPublish +``` + + +## LEGACY BELOW PENDING UPDATE Perform the release process as described below. diff --git a/dd-java-agent-ittests/dd-java-agent-ittests.gradle b/dd-java-agent-ittests/dd-java-agent-ittests.gradle index 97c63df1c1..25bb8a6e90 100644 --- a/dd-java-agent-ittests/dd-java-agent-ittests.gradle +++ b/dd-java-agent-ittests/dd-java-agent-ittests.gradle @@ -1,3 +1,5 @@ +apply from: "${rootDir}/gradle/java.gradle" + // Not adding jacoco here as it inexplicably breaks our tests. // apply from: "${rootDir}/gradle/jacoco.gradle" diff --git a/dd-java-agent/dd-java-agent.gradle b/dd-java-agent/dd-java-agent.gradle index d43d6fb0cd..7d390fbbfa 100644 --- a/dd-java-agent/dd-java-agent.gradle +++ b/dd-java-agent/dd-java-agent.gradle @@ -4,8 +4,11 @@ plugins { description = 'dd-java-agent' +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/publish.gradle" apply from: "${rootDir}/gradle/jacoco.gradle" -jacocoTestReport.dependsOn project(':dd-java-agent-ittests').test +jacocoTestReport.dependsOn ':dd-java-agent-ittests:test' + whitelistedInstructionClasses += whitelistedBranchClasses += [ "com.datadoghq.trace.agent.integration.*", 'com.datadoghq.trace.agent.AnnotationsTracingAgent', diff --git a/dd-trace-annotations/dd-trace-annotations.gradle b/dd-trace-annotations/dd-trace-annotations.gradle index a548953b44..8815caae5d 100644 --- a/dd-trace-annotations/dd-trace-annotations.gradle +++ b/dd-trace-annotations/dd-trace-annotations.gradle @@ -1,3 +1,5 @@ +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/publish.gradle" apply from: "${rootDir}/gradle/jacoco.gradle" description = 'dd-trace-annotations' diff --git a/dd-trace-examples/async-tracing/async-tracing.gradle b/dd-trace-examples/async-tracing/async-tracing.gradle index 60f3676b74..163686ea43 100644 --- a/dd-trace-examples/async-tracing/async-tracing.gradle +++ b/dd-trace-examples/async-tracing/async-tracing.gradle @@ -1,3 +1,6 @@ +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/jacoco.gradle" + description = 'async-tracing' dependencies { compile project(':dd-trace') diff --git a/dd-trace-examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle b/dd-trace-examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle index 6e6721c35d..ce02aba353 100644 --- a/dd-trace-examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle +++ b/dd-trace-examples/dropwizard-mongo-client/dropwizard-mongo-client.gradle @@ -1,3 +1,6 @@ +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/jacoco.gradle" + description = 'dropwizard-mongo-client' dependencies { compile project(':dd-trace-annotations') diff --git a/dd-trace-examples/spring-boot-jdbc/spring-boot-jdbc.gradle b/dd-trace-examples/spring-boot-jdbc/spring-boot-jdbc.gradle index cb78d7413f..ddd1d33b16 100644 --- a/dd-trace-examples/spring-boot-jdbc/spring-boot-jdbc.gradle +++ b/dd-trace-examples/spring-boot-jdbc/spring-boot-jdbc.gradle @@ -1,3 +1,6 @@ +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/jacoco.gradle" + description = 'spring-boot-jdbc' dependencies { compile group: 'com.h2database', name: 'h2', version: '1.4.196' diff --git a/dd-trace-java.gradle b/dd-trace-java.gradle index f9bd04a3b9..30f989c8bf 100644 --- a/dd-trace-java.gradle +++ b/dd-trace-java.gradle @@ -1,23 +1,13 @@ allprojects { - apply plugin: 'maven' - group = 'com.datadoghq' version = '0.1.2-SNAPSHOT' } -subprojects { - apply plugin: 'java' - sourceCompatibility = 1.7 - targetCompatibility = 1.7 - - task packageSources(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource - } - artifacts.archives packageSources +buildscript { repositories { - mavenLocal() - - maven { url "http://repo.maven.apache.org/maven2" } + jcenter() + } + dependencies { + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.18" } } diff --git a/dd-trace/dd-trace.gradle b/dd-trace/dd-trace.gradle index 07d999d617..1b63a913c5 100644 --- a/dd-trace/dd-trace.gradle +++ b/dd-trace/dd-trace.gradle @@ -5,6 +5,8 @@ plugins { description = 'dd-trace' +apply from: "${rootDir}/gradle/java.gradle" +apply from: "${rootDir}/gradle/publish.gradle" apply from: "${rootDir}/gradle/jacoco.gradle" minimumBranchCoverage = 0.3 minimumInstructionCoverage = 0.5 diff --git a/gradle/java.gradle b/gradle/java.gradle new file mode 100644 index 0000000000..cb45fdd801 --- /dev/null +++ b/gradle/java.gradle @@ -0,0 +1,14 @@ +apply plugin: 'java' +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + +task packageSources(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} +artifacts.archives packageSources +repositories { + mavenLocal() + + maven { url "http://repo.maven.apache.org/maven2" } +} diff --git a/gradle/pom.gradle b/gradle/pom.gradle new file mode 100644 index 0000000000..8a7a86b779 --- /dev/null +++ b/gradle/pom.gradle @@ -0,0 +1,62 @@ +/* + * Copyright 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Source: https://github.com/ratpack/ratpack/blob/master/gradle/pom.gradle + +ext { + pomModifications = [] + modifyPom = { pomModifications << it } +} + +tasks.withType(Upload) { + repositories.withType(org.gradle.api.artifacts.maven.MavenResolver) { + it.pom.whenConfigured { pom -> + pomModifications.each { + configure(pom, it) + } + } + } +} + +modifyPom { + dependencies.removeAll { it.scope == "test" } +} + +modifyPom { + project { + name project.name + description project.description + url "https://github.com/datadog/dd-trace-java" +// licenses { +// license { +// name "The Apache Software License, Version 2.0" +// url "http://www.apache.org/licenses/LICENSE-2.0.txt" +// distribution "repo" +// } +// } + scm { + connection "scm:https://datadog@github.com/datadog/dd-trace-java" + developerConnection "scm:git@github.com:datadog/dd-trace-java.git" + url "https://github.com/datadog/dd-trace-java" + } + developers { + developer { + id "datadog" + name "Datadog" + } + } + } +} diff --git a/gradle/publish.gradle b/gradle/publish.gradle new file mode 100644 index 0000000000..b7ec53e894 --- /dev/null +++ b/gradle/publish.gradle @@ -0,0 +1,123 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Source: https://github.com/ratpack/ratpack/blob/master/gradle/publish.gradle + +apply plugin: 'maven' +apply plugin: "com.jfrog.artifactory" +apply plugin: "signing" +apply from: "${rootDir}/gradle/pom.gradle" + +afterEvaluate { + assert description: "Project $project.path is published, must have a description" +} + +tasks.withType(Upload).matching { it.name != "install" }.all { + rootProject.subprojects { + mustRunAfter tasks.matching { it instanceof VerificationTask } + } +} + +def isSnapshot = !version.endsWith("-SNAPSHOT") + +//if (!isSnapshot) { +// tasks.withType(Upload) { +// repositories.matching { it.name == "mavenInstaller" }.all { +// beforeDeployment { deployment -> +// signing.signPom(deployment) +// } +// } +// } +//} +// +//signing { +// if (!isSnapshot) { +// required = true +// sign configurations.archives +// } +//} +// +//configurations.signatures.artifacts.all { +// extension = toSignArtifact.extension + "." + extension +//} + +configurations { + configurations { + all { + incoming.afterResolve { + dependencies.withType(ModuleDependency) { dep -> + excludeRules.each { + if ([it.group, it.module].any { it == null }) { + throw new InvalidUserDataException( + "Partial exclude for dependency '$dep.group:$dep.name:$dep.version' of $project: [group: $it.group, module: $it.module]\n\nExcludes must specify both group and module and neither can be '*'." + ) + } + } + } + } + } + } +} + +javadoc { + source = sourceSets.main.allJava + classpath = configurations.compileClasspath + + options { + setMemberLevel JavadocMemberLevel.PUBLIC + setAuthor true + + links "https://docs.oracle.com/javase/8/docs/api/" + } +} + +task sourceJar(type: Jar) { + from sourceSets.main.allJava + classifier = 'sources' +} + +task javaDocJar(type: Jar, dependsOn: javadoc) { + from javadoc.destinationDir + classifier = 'javadoc' +} + +artifacts { + archives jar + archives sourceJar + archives javaDocJar +} + +artifactoryPublish { task -> + artifactory { + publish { + contextUrl = 'http://localhost:8080/artifactory' + repository { + repoKey = !isSnapshot ? 'libs-snapshot-local' : 'libs-release-local' +// repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local' + gradle.taskGraph.whenReady { taskGraph -> + if (taskGraph.hasTask(task)) { + username = bintrayUser + password = bintrayApiKey + } + } + } + defaults { + publishConfigs('archives') + publishIvy = false + } + } + } +}