forked from reactor/reactor-core
-
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.
[build] Backport last relevant build changes from 3.3 (reactor#2156)
This includes: - using local buildSrc plugins rather than adhoc code blocks (detecting ci, java conventions, custom version) - splitting out javadoc/asciidoc gradle files - fixing the directory into which asciidocs are built - avoid building pdf reference guide locally (unless release) - remove spring-io-plugin / platform - bump asciidoctor.convert plugin - micrometer version defined in gradle.properties and pinned - reactiveStream version defined in gradle.properties - junit, awaitility, jol and testNg versions defined in properties rather than inline - use gradle enterprise plugin for buildScan - removed hamcrest-library dependency - automatic module names (see reactor#1692) The shadow plugin has been removed in 3.2.x but will be reintroduced in 3.3.x
- Loading branch information
1 parent
b3c6230
commit 9a5f9cc
Showing
14 changed files
with
764 additions
and
190 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2011-Present Pivotal Software Inc, All Rights Reserved. | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
plugins { | ||
id 'java-gradle-plugin' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.assertj:assertj-core:3.11.1") | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.2") | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
showStackTraces = true | ||
exceptionFormat = "FULL" | ||
} | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
customVersionPlugin { | ||
id = "io.reactor.gradle.custom-version" | ||
implementationClass = "io.reactor.gradle.CustomVersionPlugin" | ||
} | ||
detectCIPlugin { | ||
id = "io.reactor.gradle.detect-ci" | ||
implementationClass = "io.reactor.gradle.DetectCiPlugin" | ||
} | ||
javaConventionsPlugin { | ||
id = "io.reactor.gradle.java-conventions" | ||
implementationClass = "io.reactor.gradle.JavaConventions" | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
buildSrc/src/main/java/io/reactor/gradle/CustomVersionPlugin.java
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,67 @@ | ||
/* | ||
* Copyright (c) 2011-Present Pivotal Software Inc, All Rights Reserved. | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package io.reactor.gradle; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import org.gradle.api.InvalidUserDataException; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
|
||
/** | ||
* Looks for a {@code -PversionBranch=foo} type of property and uses that as an additional | ||
* suffix between the patch number and the snapshot qualifier ({@code .BUILD-SNAPSHOT}), in | ||
* order to generate branch-specific snapshots that can be used to eg. validate a PR. | ||
* <p> | ||
* The custom suffix must only contain alphanumeric characters. | ||
* | ||
* @author Simon Baslé | ||
*/ | ||
public class CustomVersionPlugin implements Plugin<Project> { | ||
|
||
private static final String CUSTOM_VERSION_PROPERTY = "versionBranch"; | ||
private static final String SNAPSHOT_SUFFIX = ".BUILD-SNAPSHOT"; | ||
|
||
private static final Pattern ONLY_ALPHANUMERIC_PATTERN = Pattern.compile("[A-Za-z0-9]+"); | ||
|
||
@Override | ||
public void apply(Project project) { | ||
String version = project.getVersion().toString(); | ||
Object versionBranchProperty = project.getProperties().get(CUSTOM_VERSION_PROPERTY); | ||
if (versionBranchProperty == null) { | ||
return; | ||
} | ||
|
||
String versionBranch = versionBranchProperty.toString(); | ||
//consider an empty string as "no custom version" | ||
if (versionBranch.isEmpty()) { | ||
return; | ||
} | ||
if (!ONLY_ALPHANUMERIC_PATTERN.matcher(versionBranch).matches()) { | ||
throw new InvalidUserDataException("Custom version for project passed through -PversionBranch must be alphanumeric chars only: " + versionBranch); | ||
} | ||
|
||
if (!version.endsWith(SNAPSHOT_SUFFIX)) { | ||
return; | ||
} | ||
|
||
String realVersion = version.replace(SNAPSHOT_SUFFIX, "." + versionBranch + SNAPSHOT_SUFFIX); | ||
project.setVersion(realVersion); | ||
System.out.println("Building custom snapshot for " + project + ": '" + project.getVersion()); | ||
} | ||
|
||
} |
Oops, something went wrong.