Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align with latest Gradle guidance on sharing build logic between subp…
…rojects
- Loading branch information
Showing
15 changed files
with
121 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("java-library") | ||
id("maven-publish") | ||
id("bearerauth.library-conventions") | ||
} | ||
|
||
dependencies { | ||
|
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("java-library") | ||
id("maven-publish") | ||
id("bearerauth.library-conventions") | ||
} | ||
|
||
dependencies { | ||
|
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
plugins { | ||
id("java-library") | ||
id("maven-publish") | ||
id("bearerauth.library-conventions") | ||
} | ||
|
||
java { | ||
|
1 change: 1 addition & 0 deletions
1
brisk-bearerauth-tests/brisk-bearerauth-test-micronaut/build.gradle
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id("bearerauth.java-conventions") | ||
id("application") | ||
} | ||
|
||
|
1 change: 1 addition & 0 deletions
1
brisk-bearerauth-tests/brisk-bearerauth-test-servlet/build.gradle
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
plugins { | ||
id("bearerauth.java-conventions") | ||
id("application") | ||
} | ||
|
||
|
1 change: 1 addition & 0 deletions
1
brisk-bearerauth-tests/brisk-bearerauth-test-spring-mvc/build.gradle
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
1 change: 1 addition & 0 deletions
1
brisk-bearerauth-tests/brisk-bearerauth-test-spring-webflux/build.gradle
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 |
---|---|---|
@@ -1,29 +0,0 @@ | ||
plugins { | ||
id("base") | ||
} | ||
|
||
allprojects { | ||
group = "org.briskidentity.bearerauth" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencyLocking { | ||
lockAllConfigurations() | ||
} | ||
} | ||
|
||
subprojects { | ||
apply(plugin: "java") | ||
apply(plugin: "org.briskidentity.bearerauth.conventions") | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
test { | ||
maxHeapSize = "1g" | ||
useJUnitPlatform() | ||
} | ||
} | ||
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
33 changes: 33 additions & 0 deletions
33
buildSrc/src/main/groovy/bearerauth.java-conventions.gradle
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,33 @@ | ||
import static org.briskidentity.bearerauth.build.DependencyVersionHelper.isStable; | ||
|
||
plugins { | ||
id("java") | ||
id("com.github.ben-manes.versions") | ||
id("org.briskidentity.bearerauth.conventions") | ||
} | ||
|
||
//apply(from: "gradle/dependency-versions.gradle") | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencyLocking { | ||
lockAllConfigurations() | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
test { | ||
maxHeapSize = "1g" | ||
useJUnitPlatform() | ||
} | ||
|
||
dependencyUpdates { | ||
gradleReleaseChannel = "current" | ||
rejectVersionIf { | ||
isStable(it.currentVersion) && !isStable(it.candidate.version) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
buildSrc/src/main/groovy/bearerauth.library-conventions.gradle
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,34 @@ | ||
plugins { | ||
id("bearerauth.java-conventions") | ||
id("java-library") | ||
id("maven-publish") | ||
} | ||
|
||
group = "org.briskidentity.bearerauth" | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from(components.java) | ||
pom { | ||
licenses { | ||
license { | ||
name = "The Apache License, Version 2.0" | ||
url = "https://www.apache.org/licenses/LICENSE-2.0.txt" | ||
} | ||
} | ||
scm { | ||
connection = "scm:git:git://github.com:briskidentity/brisk-bearerauth.git" | ||
developerConnection = "scm:git:ssh://git@github.com:briskidentity/brisk-bearerauth.git" | ||
url = "https://github.com/briskidentity/brisk-bearerauth" | ||
} | ||
// TODO customize POM | ||
} | ||
} | ||
} | ||
} |
53 changes: 3 additions & 50 deletions
53
buildSrc/src/main/java/org/briskidentity/bearerauth/build/ConventionsPlugin.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 |
---|---|---|
@@ -1,66 +1,19 @@ | ||
package org.briskidentity.bearerauth.build; | ||
|
||
import com.github.benmanes.gradle.versions.VersionsPlugin; | ||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.plugins.JavaPlugin; | ||
import org.gradle.api.plugins.JavaPluginExtension; | ||
import org.gradle.api.publish.PublishingExtension; | ||
import org.gradle.api.publish.maven.MavenPom; | ||
import org.gradle.api.publish.maven.MavenPublication; | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.File; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Stream; | ||
|
||
@SuppressWarnings("unused") | ||
@Deprecated | ||
public class ConventionsPlugin implements Plugin<Project> { | ||
|
||
@Override | ||
public void apply(@Nonnull Project project) { | ||
applyJavaConventions(project); | ||
applyMavenPublishConventions(project); | ||
} | ||
|
||
private void applyJavaConventions(Project project) { | ||
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { | ||
project.apply(action -> action.from(new File(project.getRootDir(), "gradle/dependency-versions.gradle"))); | ||
project.getPluginManager().apply(VersionsPlugin.class); | ||
project.getTasks().withType(DependencyUpdatesTask.class, dependencyUpdatesTask -> { | ||
dependencyUpdatesTask.setGradleReleaseChannel("current"); | ||
dependencyUpdatesTask.rejectVersionIf(candidate -> isNonStable(candidate.getCandidate().getVersion()) | ||
&& !isNonStable(candidate.getCurrentVersion())); | ||
}); | ||
}); | ||
} | ||
|
||
private static boolean isNonStable(String version) { | ||
boolean containsStableKeyword = Stream.of("RELEASE", "FINAL", "GA") | ||
.anyMatch(s -> version.toUpperCase().contains(s)); | ||
boolean isStableVersion = Pattern.compile("^[0-9,.v-]+(-r)?$").matcher(version).matches(); | ||
return !containsStableKeyword && !isStableVersion; | ||
} | ||
|
||
@SuppressWarnings("UnstableApiUsage") | ||
private void applyMavenPublishConventions(Project project) { | ||
project.getPlugins().withType(MavenPublishPlugin.class, mavenPublishPlugin -> { | ||
PublishingExtension publishingExtension = project.getExtensions().getByType(PublishingExtension.class); | ||
MavenPublication mavenPublication = publishingExtension.getPublications().create("maven", | ||
MavenPublication.class); | ||
MavenPom pom = mavenPublication.getPom(); | ||
// TODO customize POM | ||
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> { | ||
project.getComponents().matching((component) -> component.getName().equals("java")) | ||
.all(mavenPublication::from); | ||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class); | ||
javaPluginExtension.withJavadocJar(); | ||
javaPluginExtension.withSourcesJar(); | ||
}); | ||
}); | ||
|
||
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> project.apply( | ||
action -> action.from(new File(project.getRootDir(), "gradle/dependency-versions.gradle")))); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
buildSrc/src/main/java/org/briskidentity/bearerauth/build/DependencyVersionHelper.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,15 @@ | ||
package org.briskidentity.bearerauth.build; | ||
|
||
import java.util.regex.Pattern; | ||
import java.util.stream.Stream; | ||
|
||
public class DependencyVersionHelper { | ||
|
||
public static boolean isStable(String version) { | ||
boolean isStableVersion = Pattern.compile("^[0-9,.v-]+(-r)?$").matcher(version).matches(); | ||
boolean containsStableKeyword = Stream.of("RELEASE", "FINAL", "GA") | ||
.anyMatch(s -> version.toUpperCase().contains(s)); | ||
return isStableVersion || containsStableKeyword; | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
buildSrc/src/test/java/org/briskidentity/bearerauth/build/DependencyVersionHelperTests.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,14 @@ | ||
package org.briskidentity.bearerauth.build; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class DependencyVersionHelperTests { | ||
|
||
@Test | ||
void isStable() { | ||
assertTrue(DependencyVersionHelper.isStable("1.0.0")); | ||
} | ||
|
||
} |