forked from linkedin/cruise-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add release / distribute support. (linkedin#211)
- Loading branch information
Showing
30 changed files
with
360 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,26 +2,68 @@ | |
* Copyright 2017 LinkedIn Corp. Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information. | ||
*/ | ||
|
||
plugins { | ||
id "com.jfrog.artifactory" | ||
id "idea" | ||
} | ||
|
||
group = 'com.linkedin.cruisecontrol' | ||
|
||
project.ext { | ||
pomConfig = { | ||
url "https://github.com/linkedin/cruise-control" | ||
licenses { | ||
license { | ||
name "BSD 2-CLAUSE LICENSE" | ||
url "https://opensource.org/licenses/BSD-2-Clause" | ||
} | ||
} | ||
developers { | ||
developer { | ||
name "Adem Efe Gencer" | ||
email "[email protected]" | ||
} | ||
developer { | ||
name "Jiangjie (Becket) Qin" | ||
email "[email protected]" | ||
} | ||
developer { | ||
name "Sir Joel Koshy" | ||
email "[email protected]" | ||
} | ||
} | ||
scm { | ||
url "https://github.com/linkedin/cruise-control" | ||
} | ||
} | ||
} | ||
|
||
|
||
allprojects { | ||
apply plugin: 'idea' | ||
apply plugin: 'eclipse' | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
//wrapper generation task | ||
task wrapper(type: Wrapper) { | ||
gradleVersion = '4.6' | ||
} | ||
} | ||
|
||
subprojects { | ||
apply plugin: 'java' | ||
apply plugin: 'checkstyle' | ||
apply plugin: 'findbugs' | ||
|
||
test.dependsOn('checkstyleMain', 'checkstyleTest') | ||
|
||
task sourcesJar(type: Jar, dependsOn: classes) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
//code quality and inspections | ||
checkstyle { | ||
toolVersion = '7.5.1' | ||
|
@@ -62,6 +104,8 @@ subprojects { | |
} | ||
|
||
project(':cruise-control-core') { | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.jfrog.artifactory' | ||
|
||
configurations { | ||
testOutput | ||
|
@@ -75,6 +119,25 @@ project(':cruise-control-core') { | |
testOutput sourceSets.test.output | ||
} | ||
|
||
publishing { | ||
publications { | ||
java(MavenPublication) { | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode('name', 'cruise-control-core') | ||
root.appendNode('description', 'cruise control core related') | ||
root.children().last() + rootProject.ext.pomConfig | ||
} | ||
} | ||
} | ||
} | ||
|
||
artifactoryPublish.dependsOn assemble | ||
artifactoryPublish.dependsOn publishToMavenLocal | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
|
@@ -93,6 +156,8 @@ project(':cruise-control-core') { | |
|
||
project(':cruise-control') { | ||
apply plugin: 'scala' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.jfrog.artifactory' | ||
|
||
//needed because our java classes depend on scala classes, so must be compiled by scala | ||
sourceSets { | ||
|
@@ -143,6 +208,25 @@ project(':cruise-control') { | |
testCompile 'commons-io:commons-io:2.5' | ||
} | ||
|
||
publishing { | ||
publications { | ||
java(MavenPublication) { | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode('name', 'cruise-control') | ||
root.appendNode('description', 'cruise control related') | ||
root.children().last() + rootProject.ext.pomConfig | ||
} | ||
} | ||
} | ||
} | ||
|
||
artifactoryPublish.dependsOn assemble | ||
artifactoryPublish.dependsOn publishToMavenLocal | ||
|
||
tasks.create(name: "copyDependantLibs", type: Copy) { | ||
from (configurations.testRuntime) { | ||
include('slf4j-log4j12*') | ||
|
@@ -160,6 +244,8 @@ project(':cruise-control') { | |
} | ||
|
||
project(':cruise-control-metrics-reporter') { | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'com.jfrog.artifactory' | ||
|
||
configurations { | ||
testOutput | ||
|
@@ -181,5 +267,52 @@ project(':cruise-control-metrics-reporter') { | |
testOutput sourceSets.test.output | ||
} | ||
|
||
publishing { | ||
publications { | ||
java(MavenPublication) { | ||
from components.java | ||
artifact sourcesJar | ||
artifact javadocJar | ||
pom.withXml { | ||
def root = asNode() | ||
root.appendNode('name', 'cruise-control-metrics-reporter') | ||
root.appendNode('description', 'cruise control metrics reporter related') | ||
root.children().last() + rootProject.ext.pomConfig | ||
} | ||
} | ||
} | ||
} | ||
|
||
artifactoryPublish.dependsOn assemble | ||
artifactoryPublish.dependsOn publishToMavenLocal | ||
|
||
} | ||
|
||
artifactoryPublish.skip = true | ||
artifactory { | ||
contextUrl = 'https://linkedin.jfrog.io/linkedin' | ||
publish { | ||
repoKey = 'cruise-control' | ||
username = System.getenv('ARTIFACTORY_USER') | ||
password = System.getenv('ARTIFACTORY_KEY') | ||
|
||
defaults { | ||
publications ('java') | ||
publishBuildInfo = true | ||
publishArtifacts = true | ||
publishPom = true | ||
publishIvy = true | ||
} | ||
} | ||
clientConfig.setIncludeEnvVars(false) | ||
} | ||
|
||
task distributeBuild(type: com.linkedin.gradle.build.DistributeTask) { | ||
dependsOn ':artifactoryPublish', ':cruise-control:artifactoryPublish', ':cruise-control-core:artifactoryPublish', ':cruise-control-metrics-reporter:artifactoryPublish' | ||
} | ||
|
||
//wrapper generation task | ||
task wrapper(type: Wrapper) { | ||
gradleVersion = '4.6' | ||
distributionType = Wrapper.DistributionType.ALL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id "java-gradle-plugin" | ||
id "groovy" | ||
id "idea" | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile gradleApi() | ||
compile localGroovy() | ||
|
||
compile 'org.ajoberstar:gradle-git:1.2.0' | ||
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.2' | ||
compile('org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4') { | ||
exclude module: 'groovy-all' | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
buildSrc/src/main/groovy/com/linkedin/gradle/build/DistributeTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.linkedin.gradle.build | ||
|
||
import groovy.json.JsonBuilder | ||
import org.apache.http.client.fluent.Request | ||
import org.apache.http.entity.ContentType | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention | ||
|
||
class DistributeTask extends DefaultTask { | ||
|
||
@TaskAction | ||
public void distributeBuild() { | ||
ArtifactoryPluginConvention convention = project.convention.plugins.artifactory | ||
def buildNumber = convention.clientConfig.info.buildNumber | ||
def buildName = convention.clientConfig.info.buildName | ||
def context = convention.clientConfig.publisher.contextUrl | ||
def password = convention.clientConfig.publisher.password | ||
|
||
if (password == null || password.equals("")) { | ||
throw new IllegalArgumentException("password not set") | ||
} | ||
|
||
def body = [ | ||
"publish" : "true", | ||
"overrideExistingFiles": "false", | ||
"async" : "true", | ||
"targetRepo" : "maven", | ||
"sourceRepos" : ["cruise-control"], | ||
"dryRun" : "false" | ||
] | ||
|
||
def bodyString = new JsonBuilder(body).toString() | ||
|
||
def url = "$context/api/build/distribute/$buildName/$buildNumber" | ||
logger.lifecycle("url {}", url) | ||
def response = Request.Post(url) | ||
.bodyString(bodyString, ContentType.APPLICATION_JSON) | ||
.addHeader("X-JFrog-Art-Api", password) | ||
.execute() | ||
.returnResponse() | ||
|
||
def bout = new ByteArrayOutputStream() | ||
response.getEntity().writeTo(bout); | ||
String errMsg = new String(bout.toByteArray()); | ||
logger.lifecycle("Distribute Response: {} {}", response, errMsg) | ||
|
||
if (!Integer.toString(response.getStatusLine().getStatusCode()).startsWith("2")) { | ||
throw new IOException("http post failed") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.