Enable uploading to local artifactory.

This commit is contained in:
Tyler Benson 2017-07-11 10:53:25 -07:00
parent 78969ce6f0
commit 840ada4650
12 changed files with 238 additions and 30 deletions

View File

@ -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
<settings>
<servers>
<server>
<id>nexus-local</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>
```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.

View File

@ -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"

View File

@ -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',

View File

@ -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'

View File

@ -1,3 +1,6 @@
apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/jacoco.gradle"
description = 'async-tracing'
dependencies {
compile project(':dd-trace')

View File

@ -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')

View File

@ -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'

View File

@ -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"
}
}

View File

@ -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

14
gradle/java.gradle Normal file
View File

@ -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" }
}

62
gradle/pom.gradle Normal file
View File

@ -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"
}
}
}
}

123
gradle/publish.gradle Normal file
View File

@ -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
}
}
}
}