From e2ba054f1b8cd1d1d90248ce5cbdc597419aa29e Mon Sep 17 00:00:00 2001 From: Mark Vulfson Date: Tue, 18 Jun 2019 11:13:21 -0700 Subject: [PATCH] feat(front50-bom): publish front50-bom (#547) * feat(front50-bom): publish front50-bom This simplifies dependency resolution downstream --- build.gradle | 57 ++++++++++--------- front50-bom/front50-bom.gradle | 52 +++++++++++++++++ .../spinnaker/front50/model/ItemDAO.java | 4 +- .../front50/model/StorageService.java | 2 +- .../front50/validator/PipelineValidator.java | 2 +- gradle/buildViaTravis.sh | 6 +- gradle/init-publish.gradle | 14 ----- gradle/installViaTravis.sh | 4 +- settings.gradle | 12 +++- 9 files changed, 102 insertions(+), 51 deletions(-) create mode 100644 front50-bom/front50-bom.gradle delete mode 100644 gradle/init-publish.gradle diff --git a/build.gradle b/build.gradle index e7e953094..64cf0ed12 100644 --- a/build.gradle +++ b/build.gradle @@ -29,47 +29,48 @@ buildscript { } allprojects { project -> + group = "com.netflix.spinnaker.front50" apply plugin: 'spinnaker.base-project' if (Boolean.valueOf(enablePublishing)) { apply plugin: "spinnaker.project" } - apply plugin: 'java-library' - apply plugin: 'groovy' - group = "com.netflix.spinnaker.front50" + if (name != "front50-bom") { + apply plugin: 'java-library' + apply plugin: 'groovy' - test { - testLogging { - exceptionFormat = 'full' + test { + testLogging { + exceptionFormat = 'full' + } } - } - tasks.withType(JavaExec) { - if (System.getProperty('DEBUG', 'false') == 'true') { - jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8180' + tasks.withType(JavaExec) { + if (System.getProperty('DEBUG', 'false') == 'true') { + jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8180' + } } - } - dependencies { - implementation platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion") - annotationProcessor platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion") - testAnnotationProcessor platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion") + dependencies { + implementation(platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion")) + annotationProcessor(platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion")) + testAnnotationProcessor(platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion")) - implementation "org.codehaus.groovy:groovy-all" - implementation "net.logstash.logback:logstash-logback-encoder" + implementation("org.codehaus.groovy:groovy-all") + implementation("net.logstash.logback:logstash-logback-encoder") - compileOnly "org.projectlombok:lombok" - annotationProcessor "org.projectlombok:lombok" - testAnnotationProcessor "org.projectlombok:lombok" + compileOnly("org.projectlombok:lombok") + annotationProcessor("org.projectlombok:lombok") + testAnnotationProcessor("org.projectlombok:lombok") - testImplementation "org.spockframework:spock-core" - testImplementation "org.springframework.boot:spring-boot-starter-test" - testImplementation "org.spockframework:spock-core" - testImplementation "org.spockframework:spock-spring" - testImplementation "org.springframework:spring-test" - testImplementation "org.hamcrest:hamcrest-core" - testRuntimeOnly "cglib:cglib-nodep" - testRuntimeOnly "org.objenesis:objenesis" + testImplementation("org.spockframework:spock-core") + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.spockframework:spock-spring") + testImplementation("org.springframework:spring-test") + testImplementation("org.hamcrest:hamcrest-core") + testRuntimeOnly("cglib:cglib-nodep") + testRuntimeOnly("org.objenesis:objenesis") + } } } diff --git a/front50-bom/front50-bom.gradle b/front50-bom/front50-bom.gradle new file mode 100644 index 000000000..bf47dbbed --- /dev/null +++ b/front50-bom/front50-bom.gradle @@ -0,0 +1,52 @@ +/* + * Copyright 2019 Netflix, Inc. + * + * 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. + */ + +apply plugin: "java-platform" +apply plugin: "maven-publish" + +// without this building the pom fails when using the Nebula publishing plugin +configurations { + create("compileOnly") +} + +javaPlatform { + allowDependencies() +} + + +if (Boolean.valueOf(enablePublishing)) { + publishing { + publications { + nebula(MavenPublication) { + from components.javaPlatform + } + } + } +} + +dependencies { + api(platform("com.netflix.spinnaker.kork:kork-bom:$korkVersion")) + + constraints { + api("com.netflix.spinnaker.fiat:fiat-api:$fiatVersion") + api("com.netflix.spinnaker.fiat:fiat-core:$fiatVersion") + + rootProject + .subprojects + .findAll { it != project } + .each { api(project(it.path)) } + } +} diff --git a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/ItemDAO.java b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/ItemDAO.java index 4cf69500e..46eb2e5e9 100644 --- a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/ItemDAO.java +++ b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/ItemDAO.java @@ -12,7 +12,9 @@ public interface ItemDAO { /** * It can be expensive to refresh a bucket containing a large number of objects. * - *

When {@code refresh} is false, the most recently cached set of objects will be returned. + * @param refresh true to refresh + * @return When {@code refresh} is false, the most recently cached set of objects will be + * returned. * */ Collection all(boolean refresh); diff --git a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/StorageService.java b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/StorageService.java index ae5a0bc8a..6529bb792 100644 --- a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/StorageService.java +++ b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/model/StorageService.java @@ -26,7 +26,7 @@ public interface StorageService { /** Check to see if the bucket exists, creating it if it is not there. */ void ensureBucketExists(); - /** Returns true if the storage service supports versioning. */ + /** @return true if the storage service supports versioning. */ boolean supportsVersioning(); default boolean supportsEventing(ObjectType objectType) { diff --git a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/validator/PipelineValidator.java b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/validator/PipelineValidator.java index a45d6dc96..3559cdad7 100644 --- a/front50-core/src/main/groovy/com/netflix/spinnaker/front50/validator/PipelineValidator.java +++ b/front50-core/src/main/groovy/com/netflix/spinnaker/front50/validator/PipelineValidator.java @@ -23,7 +23,7 @@ public interface PipelineValidator { /** * @param pipeline the pipeline being modified - * @param errors specific validation errors for {@param pipeline} + * @param errors specific validation errors for @param pipeline */ void validate(Pipeline pipeline, Errors errors); } diff --git a/gradle/buildViaTravis.sh b/gradle/buildViaTravis.sh index 7f755d9ff..c9f9a495a 100755 --- a/gradle/buildViaTravis.sh +++ b/gradle/buildViaTravis.sh @@ -1,11 +1,11 @@ #!/bin/bash # This script will build the project. -GRADLE="./gradlew -I gradle/init-publish.gradle" +GRADLE="./gradlew -PenablePublishing=true" if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then echo -e "Build Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]" - $GRADLE -Prelease.useLastTag=true build + $GRADLE build elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']' $GRADLE -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" build snapshot --stacktrace @@ -23,6 +23,6 @@ elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then esac else echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']' - $GRADLE -Prelease.useLastTag=true build + $GRADLE build fi diff --git a/gradle/init-publish.gradle b/gradle/init-publish.gradle deleted file mode 100644 index 226921504..000000000 --- a/gradle/init-publish.gradle +++ /dev/null @@ -1,14 +0,0 @@ -initscript { - repositories { - mavenLocal() - jcenter() - maven { url 'https://dl.bintray.com/spinnaker/gradle/' } - maven { url "https://plugins.gradle.org/m2/" } - } - dependencies { - classpath 'com.netflix.spinnaker.gradle:spinnaker-gradle-project:5.1.4' - } -} - -// Can't use the plugin ID (spinnaker.project) on init scripts for some reason. -apply plugin: com.netflix.spinnaker.gradle.project.SpinnakerProjectPlugin diff --git a/gradle/installViaTravis.sh b/gradle/installViaTravis.sh index 292344d7d..9b21f349f 100755 --- a/gradle/installViaTravis.sh +++ b/gradle/installViaTravis.sh @@ -1,7 +1,7 @@ #!/bin/bash # This script will build the project. -GRADLE="./gradlew -I gradle/init-publish.gradle" +GRADLE="./gradlew -PenablePublishing=true" if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then echo -e "Assemble Pull Request #$TRAVIS_PULL_REQUEST => Branch [$TRAVIS_BRANCH]" @@ -11,7 +11,7 @@ elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then $GRADLE -Prelease.travisci=true assemble elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" != "" ]; then echo -e 'Assemble Branch for Release => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG']' - $GRADLE -Prelease.travisci=true -Prelease.useLastTag=true assemble + $GRADLE -Prelease.travisci=true assemble else echo -e 'WARN: Should not be here => Branch ['$TRAVIS_BRANCH'] Tag ['$TRAVIS_TAG'] Pull Request ['$TRAVIS_PULL_REQUEST']' $GRADLE assemble diff --git a/settings.gradle b/settings.gradle index 6fe89ed34..5f30f2e3b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -16,7 +16,17 @@ rootProject.name = "front50" -include 'front50-web', 'front50-core', 'front50-gcs', 'front50-redis', 'front50-s3', 'front50-test', 'front50-migrations', 'front50-azure', 'front50-swift', 'front50-oracle' +include 'front50-web', + 'front50-core', + 'front50-gcs', + 'front50-redis', + 'front50-s3', + 'front50-test', + 'front50-migrations', + 'front50-azure', + 'front50-swift', + 'front50-oracle', + 'front50-bom' def setBuildFile(project) { project.buildFileName = "${project.name}.gradle"