[Build] Simplify build
- Consolidate plugins to pulsar package - Remove prohibited classpath check
This commit is contained in:
63
build.gradle
63
build.gradle
@@ -8,23 +8,16 @@ plugins {
|
||||
description = 'Spring for Apache Pulsar'
|
||||
|
||||
apply from: 'gradle/aggregate-jacoco-report.gradle'
|
||||
apply from: 'gradle/update-copyrights.gradle'
|
||||
|
||||
def gitPresent = new File('.git').exists()
|
||||
|
||||
if (gitPresent) {
|
||||
apply plugin: 'org.ajoberstar.grgit'
|
||||
}
|
||||
|
||||
ext {
|
||||
if (gitPresent) {
|
||||
modifiedFiles = files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') }
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
group = 'org.springframework.pulsar'
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
|
||||
resolutionStrategy {
|
||||
cacheChangingModulesFor 0, "seconds"
|
||||
cacheDynamicVersionsFor 0, "seconds"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,49 +39,3 @@ nohttp {
|
||||
check {
|
||||
dependsOn checkstyleNohttp
|
||||
}
|
||||
|
||||
/**
|
||||
* Update copyrights for modified files:
|
||||
* 'gradle updateCopyrights'
|
||||
*
|
||||
* Update copyrights for ALL files:
|
||||
* 'gradle updateCopyrights -Pall=true'
|
||||
*/
|
||||
subprojects { subproject ->
|
||||
task updateCopyrights {
|
||||
if (findProperty("all") == "true") {
|
||||
inputs.files(fileTree("${projectDir}").matching {
|
||||
include "**/*.java"
|
||||
}.files)
|
||||
}
|
||||
else {
|
||||
onlyIf { gitPresent && !System.getenv('GITHUB_ACTION') }
|
||||
if (gitPresent) {
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
}
|
||||
}
|
||||
outputs.dir('build')
|
||||
doLast {
|
||||
def now = Calendar.instance.get(Calendar.YEAR) as String
|
||||
inputs.files.each { file ->
|
||||
def line
|
||||
file.withReader { reader ->
|
||||
while (line = reader.readLine()) {
|
||||
def matcher = line =~ /Copyright (20\d\d)-?(20\d\d)?/
|
||||
if (matcher.count) {
|
||||
def beginningYear = matcher[0][1]
|
||||
if (now != beginningYear && now != matcher[0][2]) {
|
||||
def years = "$beginningYear-$now"
|
||||
def sourceCode = file.text
|
||||
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
|
||||
file.write(sourceCode)
|
||||
println "Copyright updated for file: $file"
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,22 +62,26 @@ dependencies {
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
artifactoryPlugin {
|
||||
id = "io.spring.convention.artfiactory"
|
||||
implementationClass = "io.spring.gradle.convention.ArtifactoryPlugin"
|
||||
}
|
||||
jacocoConventionsPlugin {
|
||||
id = "org.springframework.pulsar.jacoco"
|
||||
implementationClass = "org.springframework.pulsar.gradle.JacocoConventionsPlugin"
|
||||
implementationClass = "org.springframework.pulsar.gradle.check.JacocoConventionsPlugin"
|
||||
}
|
||||
optionalDependenciesPlugin {
|
||||
id = "org.springframework.pulsar.optional-dependencies"
|
||||
implementationClass = "org.springframework.boot.gradle.optional.OptionalDependenciesPlugin"
|
||||
implementationClass = "org.springframework.pulsar.gradle.optional.OptionalDependenciesPlugin"
|
||||
}
|
||||
repositoryConventionPlugin {
|
||||
id = "io.spring.convention.repository"
|
||||
implementationClass = "io.spring.gradle.convention.RepositoryConventionPlugin"
|
||||
}
|
||||
rootProjectPlugin {
|
||||
id = "org.springframework.pulsar.root-project"
|
||||
implementationClass = "org.springframework.pulsar.gradle.RootProjectPlugin"
|
||||
}
|
||||
sonarQubeConventionsPlugin {
|
||||
id = "org.springframework.pulsar.sonarqube"
|
||||
implementationClass = "org.springframework.pulsar.gradle.SonarQubeConventionsPlugin"
|
||||
}
|
||||
springDocsModulePlugin {
|
||||
id = "org.springframework.pulsar.spring-docs-module"
|
||||
implementationClass = "org.springframework.pulsar.gradle.SpringDocsModulePlugin"
|
||||
@@ -86,18 +90,13 @@ gradlePlugin {
|
||||
id = "org.springframework.pulsar.spring-module"
|
||||
implementationClass = "org.springframework.pulsar.gradle.SpringModulePlugin"
|
||||
}
|
||||
sonarQubeConventionsPlugin {
|
||||
id = "org.springframework.pulsar.sonarqube"
|
||||
implementationClass = "org.springframework.pulsar.gradle.check.SonarQubeConventionsPlugin"
|
||||
}
|
||||
updateProjectVersion {
|
||||
id = "org.springframework.pulsar.update-version"
|
||||
implementationClass = "org.springframework.pulsar.gradle.versions.UpdateProjectVersionPlugin"
|
||||
}
|
||||
// groovy plugins
|
||||
artifactoryPlugin {
|
||||
id = "io.spring.convention.artfiactory"
|
||||
implementationClass = "io.spring.gradle.convention.ArtifactoryPlugin"
|
||||
}
|
||||
repositoryConventionPlugin {
|
||||
id = "io.spring.convention.repository"
|
||||
implementationClass = "io.spring.gradle.convention.RepositoryConventionPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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
|
||||
*
|
||||
* 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 org.springframework.boot.gradle.classpath;
|
||||
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.GradleException;
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.ModuleVersionIdentifier;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.tasks.Classpath;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
|
||||
/**
|
||||
* A {@link Task} for checking the classpath for prohibited dependencies.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
||||
|
||||
private Configuration classpath;
|
||||
|
||||
public CheckClasspathForProhibitedDependencies() {
|
||||
getOutputs().upToDateWhen((task) -> true);
|
||||
}
|
||||
|
||||
public void setClasspath(Configuration classpath) {
|
||||
this.classpath = classpath;
|
||||
}
|
||||
|
||||
@Classpath
|
||||
public FileCollection getClasspath() {
|
||||
return this.classpath;
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void checkForProhibitedDependencies() {
|
||||
TreeSet<String> prohibited = this.classpath.getResolvedConfiguration().getResolvedArtifacts().stream()
|
||||
.map((artifact) -> artifact.getModuleVersion().getId()).filter(this::prohibited)
|
||||
.map((id) -> id.getGroup() + ":" + id.getName()).collect(Collectors.toCollection(TreeSet::new));
|
||||
if (!prohibited.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder("Found prohibited dependencies:%n".formatted());
|
||||
for (String dependency : prohibited) {
|
||||
message.append(" %s%n".formatted(dependency));
|
||||
}
|
||||
throw new GradleException(message.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean prohibited(ModuleVersionIdentifier id) {
|
||||
return prohibitedByDefault(id) ? !overrideProhibited(id) : false;
|
||||
}
|
||||
|
||||
private boolean prohibitedByDefault(ModuleVersionIdentifier id) {
|
||||
String group = id.getGroup();
|
||||
if (group.equals("javax.batch")) {
|
||||
return false;
|
||||
}
|
||||
if (group.equals("javax.cache")) {
|
||||
return false;
|
||||
}
|
||||
if (group.equals("javax.money")) {
|
||||
return false;
|
||||
}
|
||||
if (group.startsWith("javax")) {
|
||||
return true;
|
||||
}
|
||||
if (group.equals("org.codehaus.groovy")) {
|
||||
return true;
|
||||
}
|
||||
if (group.equals("org.eclipse.jetty.toolchain")) {
|
||||
return true;
|
||||
}
|
||||
if (group.equals("commons-logging")) {
|
||||
return true;
|
||||
}
|
||||
if (group.equals("org.slf4j") && id.getName().equals("jcl-over-slf4j")) {
|
||||
return true;
|
||||
}
|
||||
if (group.startsWith("org.jboss.spec")) {
|
||||
return true;
|
||||
}
|
||||
if (group.equals("org.apache.geronimo.specs")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean overrideProhibited(ModuleVersionIdentifier id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle;
|
||||
package org.springframework.pulsar.gradle;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle;
|
||||
package org.springframework.pulsar.gradle;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -24,9 +24,6 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
||||
import io.spring.javaformat.gradle.tasks.CheckFormat;
|
||||
import io.spring.javaformat.gradle.tasks.Format;
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
@@ -50,12 +47,13 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat;
|
||||
import org.gradle.api.tasks.testing.logging.TestLogEvent;
|
||||
import org.gradle.external.javadoc.CoreJavadocOptions;
|
||||
|
||||
import org.springframework.boot.gradle.classpath.CheckClasspathForProhibitedDependencies;
|
||||
import org.springframework.boot.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.boot.gradle.testing.TestFailuresPlugin;
|
||||
import org.springframework.boot.gradle.toolchain.ToolchainPlugin;
|
||||
import org.springframework.pulsar.gradle.classpath.LenientCheckClasspathForProhibitedDependencies;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.pulsar.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.pulsar.gradle.testing.TestFailuresPlugin;
|
||||
import org.springframework.pulsar.gradle.toolchain.ToolchainPlugin;
|
||||
|
||||
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
||||
import io.spring.javaformat.gradle.tasks.CheckFormat;
|
||||
import io.spring.javaformat.gradle.tasks.Format;
|
||||
|
||||
/**
|
||||
* Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the
|
||||
@@ -110,7 +108,6 @@ public class JavaConventionsPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(Project project) {
|
||||
project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
|
||||
project.getPlugins().apply(TestFailuresPlugin.class);
|
||||
configureSpringJavaFormat(project);
|
||||
configureJavaConventions(project);
|
||||
configureJavadocConventions(project);
|
||||
@@ -118,10 +115,82 @@ public class JavaConventionsPlugin implements Plugin<Project> {
|
||||
configureJarManifestConventions(project);
|
||||
configureDependencyManagement(project);
|
||||
configureToolchain(project);
|
||||
configureProhibitedDependencyChecks(project);
|
||||
});
|
||||
}
|
||||
|
||||
private void configureSpringJavaFormat(Project project) {
|
||||
project.getPlugins().apply(SpringJavaFormatPlugin.class);
|
||||
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));
|
||||
project.getPlugins().apply(CheckstylePlugin.class);
|
||||
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
|
||||
checkstyle.setToolVersion("8.45.1");
|
||||
checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle"));
|
||||
String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion();
|
||||
DependencySet checkstyleDependencies = project.getConfigurations().getByName("checkstyle").getDependencies();
|
||||
checkstyleDependencies
|
||||
.add(project.getDependencies().create("io.spring.javaformat:spring-javaformat-checkstyle:" + version));
|
||||
}
|
||||
|
||||
private void configureJavaConventions(Project project) {
|
||||
if (!project.hasProperty("toolchainVersion")) {
|
||||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||
}
|
||||
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
||||
compile.getOptions().setEncoding("UTF-8");
|
||||
List<String> args = compile.getOptions().getCompilerArgs();
|
||||
if (!args.contains("-parameters")) {
|
||||
args.add("-parameters");
|
||||
}
|
||||
if (project.hasProperty("toolchainVersion")) {
|
||||
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
}
|
||||
else if (buildingWithJava17(project)) {
|
||||
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
|
||||
"-Xlint:varargs"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean buildingWithJava17(Project project) {
|
||||
return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_17;
|
||||
}
|
||||
|
||||
private void configureJavadocConventions(Project project) {
|
||||
project.getTasks().withType(Javadoc.class, (javadoc) -> {
|
||||
CoreJavadocOptions options = (CoreJavadocOptions) javadoc.getOptions();
|
||||
options.source("17");
|
||||
options.encoding("UTF-8");
|
||||
options.addStringOption("Xdoclint:none", "-quiet");
|
||||
});
|
||||
}
|
||||
|
||||
private void configureTestConventions(Project project) {
|
||||
project.getPlugins().apply(TestFailuresPlugin.class);
|
||||
project.getTasks().withType(Test.class, (test) -> {
|
||||
test.useJUnitPlatform();
|
||||
test.setMaxHeapSize("1024M");
|
||||
test.testLogging(testLoggingContainer -> {
|
||||
testLoggingContainer.setEvents(Set.of(TestLogEvent.SKIPPED, TestLogEvent.FAILED));
|
||||
testLoggingContainer.setShowStandardStreams(project.hasProperty("showStandardStreams"));
|
||||
testLoggingContainer.setShowExceptions(true);
|
||||
testLoggingContainer.setShowStackTraces(true);
|
||||
testLoggingContainer.setExceptionFormat(TestExceptionFormat.FULL);
|
||||
});
|
||||
test.jvmArgs(
|
||||
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
|
||||
"--add-opens", "java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
|
||||
);
|
||||
test.getTestLogging().setShowStandardStreams(true);
|
||||
project.getTasks().withType(Checkstyle.class, test::mustRunAfter);
|
||||
project.getTasks().withType(CheckFormat.class, test::mustRunAfter);
|
||||
});
|
||||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies()
|
||||
.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher"));
|
||||
}
|
||||
|
||||
private void configureJarManifestConventions(Project project) {
|
||||
ExtractResources extractLegalResources = project.getTasks().create("extractLegalResources",
|
||||
ExtractResources.class);
|
||||
@@ -159,77 +228,6 @@ public class JavaConventionsPlugin implements Plugin<Project> {
|
||||
return project.getDescription();
|
||||
}
|
||||
|
||||
private void configureTestConventions(Project project) {
|
||||
project.getTasks().withType(Test.class, (test) -> {
|
||||
test.useJUnitPlatform();
|
||||
test.setMaxHeapSize("1024M");
|
||||
test.testLogging(testLoggingContainer -> {
|
||||
testLoggingContainer.setEvents(Set.of(TestLogEvent.SKIPPED, TestLogEvent.FAILED));
|
||||
testLoggingContainer.setShowStandardStreams(project.hasProperty("showStandardStreams"));
|
||||
testLoggingContainer.setShowExceptions(true);
|
||||
testLoggingContainer.setShowStackTraces(true);
|
||||
testLoggingContainer.setExceptionFormat(TestExceptionFormat.FULL);
|
||||
});
|
||||
test.jvmArgs(
|
||||
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
|
||||
"--add-opens", "java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens", "java.base/sun.net=ALL-UNNAMED"
|
||||
);
|
||||
project.getTasks().withType(Checkstyle.class, test::mustRunAfter);
|
||||
project.getTasks().withType(CheckFormat.class, test::mustRunAfter);
|
||||
});
|
||||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies()
|
||||
.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher"));
|
||||
}
|
||||
|
||||
private void configureJavadocConventions(Project project) {
|
||||
project.getTasks().withType(Javadoc.class, (javadoc) -> {
|
||||
CoreJavadocOptions options = (CoreJavadocOptions) javadoc.getOptions();
|
||||
options.source("17");
|
||||
options.encoding("UTF-8");
|
||||
options.addStringOption("Xdoclint:none", "-quiet");
|
||||
});
|
||||
}
|
||||
|
||||
private void configureJavaConventions(Project project) {
|
||||
if (!project.hasProperty("toolchainVersion")) {
|
||||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||
}
|
||||
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
||||
compile.getOptions().setEncoding("UTF-8");
|
||||
List<String> args = compile.getOptions().getCompilerArgs();
|
||||
if (!args.contains("-parameters")) {
|
||||
args.add("-parameters");
|
||||
}
|
||||
if (project.hasProperty("toolchainVersion")) {
|
||||
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
}
|
||||
else if (buildingWithJava17(project)) {
|
||||
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
|
||||
"-Xlint:varargs"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean buildingWithJava17(Project project) {
|
||||
return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_17;
|
||||
}
|
||||
|
||||
private void configureSpringJavaFormat(Project project) {
|
||||
project.getPlugins().apply(SpringJavaFormatPlugin.class);
|
||||
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));
|
||||
project.getPlugins().apply(CheckstylePlugin.class);
|
||||
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
|
||||
checkstyle.setToolVersion("8.45.1");
|
||||
checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle"));
|
||||
String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion();
|
||||
DependencySet checkstyleDependencies = project.getConfigurations().getByName("checkstyle").getDependencies();
|
||||
checkstyleDependencies
|
||||
.add(project.getDependencies().create("io.spring.javaformat:spring-javaformat-checkstyle:" + version));
|
||||
}
|
||||
|
||||
private void configureDependencyManagement(Project project) {
|
||||
ConfigurationContainer configurations = project.getConfigurations();
|
||||
Configuration dependencyManagement = configurations.create("dependencyManagement", (configuration) -> {
|
||||
@@ -251,27 +249,4 @@ public class JavaConventionsPlugin implements Plugin<Project> {
|
||||
project.getPlugins().apply(ToolchainPlugin.class);
|
||||
}
|
||||
|
||||
private void configureProhibitedDependencyChecks(Project project) {
|
||||
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
||||
sourceSets.matching((sourceSet) -> !sourceSet.getName().equals("intTest"))
|
||||
.all((sourceSet) -> createProhibitedDependenciesChecks(project,
|
||||
sourceSet.getCompileClasspathConfigurationName(), sourceSet.getRuntimeClasspathConfigurationName()));
|
||||
}
|
||||
|
||||
private void createProhibitedDependenciesChecks(Project project, String... configurationNames) {
|
||||
ConfigurationContainer configurations = project.getConfigurations();
|
||||
for (String configurationName : configurationNames) {
|
||||
Configuration configuration = configurations.getByName(configurationName);
|
||||
createProhibitedDependenciesCheck(configuration, project);
|
||||
}
|
||||
}
|
||||
|
||||
private void createProhibitedDependenciesCheck(Configuration classpath, Project project) {
|
||||
CheckClasspathForProhibitedDependencies checkClasspathForProhibitedDependencies = project.getTasks().create(
|
||||
"check" + StringUtils.capitalize(classpath.getName() + "ForProhibitedDependencies"),
|
||||
LenientCheckClasspathForProhibitedDependencies.class);
|
||||
checkClasspathForProhibitedDependencies.setClasspath(classpath);
|
||||
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2022-2022 the original author or authors.
|
||||
* Copyright 2022-2023 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.
|
||||
@@ -24,6 +24,7 @@ import org.gradle.api.Task;
|
||||
import org.gradle.api.plugins.BasePlugin;
|
||||
import org.gradle.api.plugins.PluginManager;
|
||||
|
||||
import org.springframework.pulsar.gradle.check.SonarQubeConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.SpringNexusPublishPlugin;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,9 +23,8 @@ import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.PluginManager;
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
||||
|
||||
import org.springframework.boot.gradle.JavaConventionsPlugin;
|
||||
import org.springframework.boot.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.pulsar.gradle.docs.asciidoc.AsciidoctorConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.docs.AsciidoctorConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.MavenPublishingConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.PublishArtifactsPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.PublishLocalPlugin;
|
||||
@@ -35,7 +34,6 @@ import io.spring.gradle.convention.ArtifactoryPlugin;
|
||||
import io.spring.gradle.convention.RepositoryConventionPlugin;
|
||||
|
||||
/**
|
||||
* @author Rob Winch
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class SpringDocsModulePlugin implements Plugin<Project> {
|
||||
|
||||
@@ -23,9 +23,8 @@ import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.PluginManager;
|
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
||||
|
||||
import org.springframework.boot.gradle.JavaConventionsPlugin;
|
||||
import org.springframework.boot.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.pulsar.gradle.docs.asciidoc.AsciidoctorConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.check.JacocoConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.MavenPublishingConventionsPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.PublishAllJavaComponentsPlugin;
|
||||
import org.springframework.pulsar.gradle.publish.PublishArtifactsPlugin;
|
||||
@@ -42,12 +41,12 @@ public class SpringModulePlugin implements Plugin<Project> {
|
||||
|
||||
@Override
|
||||
public void apply(final Project project) {
|
||||
|
||||
PluginManager pluginManager = project.getPluginManager();
|
||||
pluginManager.apply(JavaPlugin.class);
|
||||
pluginManager.apply(RepositoryConventionPlugin.class);
|
||||
pluginManager.apply(JavaLibraryPlugin.class);
|
||||
pluginManager.apply(JavaConventionsPlugin.class);
|
||||
pluginManager.apply(AsciidoctorConventionsPlugin.class);
|
||||
pluginManager.apply(MavenPublishPlugin.class);
|
||||
pluginManager.apply(SpringSigningPlugin.class);
|
||||
pluginManager.apply(MavenPublishingConventionsPlugin.class);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.pulsar.gradle;
|
||||
package org.springframework.pulsar.gradle.check;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
@@ -18,12 +18,9 @@ public class JacocoConventionsPlugin implements Plugin<Project> {
|
||||
@Override
|
||||
public void apply(final Project project) {
|
||||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
|
||||
|
||||
project.getPluginManager().apply(JacocoPlugin.class);
|
||||
|
||||
project.getExtensions().configure(JacocoPluginExtension.class,
|
||||
(jacocoExtension) -> jacocoExtension.setToolVersion("0.8.7"));
|
||||
|
||||
project.getTasks().withType(Test.class, (test) ->
|
||||
project.getTasks().withType(JacocoReport.class, test::finalizedBy));
|
||||
});
|
||||
@@ -1,10 +1,12 @@
|
||||
package org.springframework.pulsar.gradle;
|
||||
package org.springframework.pulsar.gradle.check;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
import org.sonarqube.gradle.SonarQubeExtension;
|
||||
import org.sonarqube.gradle.SonarQubePlugin;
|
||||
|
||||
import org.springframework.pulsar.gradle.ProjectLinks;
|
||||
|
||||
/**
|
||||
* Adds a version of SonarQube to use and configures it.
|
||||
*
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022-2022 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
|
||||
*
|
||||
* 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 org.springframework.pulsar.gradle.classpath;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.gradle.api.Task;
|
||||
import org.gradle.api.artifacts.ModuleVersionIdentifier;
|
||||
|
||||
import org.springframework.boot.gradle.classpath.CheckClasspathForProhibitedDependencies;
|
||||
|
||||
/**
|
||||
* Extends the Spring Boot {@link Task} for checking the classpath for prohibited dependencies in a more lenient fashion
|
||||
* and allows the PulsarClient to bring in some of the {@code javax.*} dependencies.
|
||||
*
|
||||
* @author Chris Bono
|
||||
*/
|
||||
public class LenientCheckClasspathForProhibitedDependencies extends CheckClasspathForProhibitedDependencies {
|
||||
|
||||
private static Set<String> OVERRIDE_PROHIBITED_DEPENDENCIES = Set.of(
|
||||
"javax.validation:validation-api",
|
||||
"javax.ws.rs:javax.ws.rs-api",
|
||||
"javax.inject:javax.inject",
|
||||
"javax.xml.bind:jaxb-api",
|
||||
"commons-logging:commons-logging");
|
||||
|
||||
@Override
|
||||
protected boolean overrideProhibited(ModuleVersionIdentifier id) {
|
||||
return OVERRIDE_PROHIBITED_DEPENDENCIES.contains(id.getGroup() + ":" + id.getName());
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.pulsar.gradle.docs.asciidoc;
|
||||
package org.springframework.pulsar.gradle.docs;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.optional;
|
||||
package org.springframework.pulsar.gradle.optional;
|
||||
|
||||
import org.gradle.api.Plugin;
|
||||
import org.gradle.api.Project;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.testing;
|
||||
package org.springframework.pulsar.gradle.testing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.testing;
|
||||
package org.springframework.pulsar.gradle.testing;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.toolchain;
|
||||
package org.springframework.pulsar.gradle.toolchain;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.provider.ListProperty;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.gradle.toolchain;
|
||||
package org.springframework.pulsar.gradle.toolchain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
61
gradle/update-copyrights.gradle
Normal file
61
gradle/update-copyrights.gradle
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
def gitPresent = new File('.git').exists()
|
||||
if (gitPresent) {
|
||||
apply plugin: 'org.ajoberstar.grgit'
|
||||
}
|
||||
|
||||
ext {
|
||||
if (gitPresent) {
|
||||
modifiedFiles = files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') }
|
||||
}
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
|
||||
/**
|
||||
* Update copyrights for modified files:
|
||||
* 'gradle updateCopyrights'
|
||||
*
|
||||
* Update copyrights for ALL files:
|
||||
* 'gradle updateCopyrights -Pall=true'
|
||||
*/
|
||||
subprojects { subproject ->
|
||||
task updateCopyrights {
|
||||
if (findProperty("all") == "true") {
|
||||
inputs.files(fileTree("${projectDir}").matching {
|
||||
include "**/*.java"
|
||||
}.files)
|
||||
}
|
||||
else {
|
||||
onlyIf { gitPresent && !System.getenv('GITHUB_ACTION') }
|
||||
if (gitPresent) {
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
}
|
||||
}
|
||||
outputs.dir('build')
|
||||
doLast {
|
||||
def now = Calendar.instance.get(Calendar.YEAR) as String
|
||||
inputs.files.each { file ->
|
||||
def line
|
||||
file.withReader { reader ->
|
||||
while (line = reader.readLine()) {
|
||||
def matcher = line =~ /Copyright (20\d\d)-?(20\d\d)?/
|
||||
if (matcher.count) {
|
||||
def beginningYear = matcher[0][1]
|
||||
if (now != beginningYear && now != matcher[0][2]) {
|
||||
def years = "$beginningYear-$now"
|
||||
def sourceCode = file.text
|
||||
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
|
||||
file.write(sourceCode)
|
||||
println "Copyright updated for file: $file"
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +1,17 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.spring.io/plugins-milestone' }
|
||||
maven { url 'https://repo.spring.io/plugins-snapshot' }
|
||||
jcenter()
|
||||
gradlePluginPortal()
|
||||
maven { url "https://repo.spring.io/release" }
|
||||
maven { url "https://repo.spring.io/snapshot" }
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gradle.enterprise' version '3.10.2'
|
||||
id 'io.spring.ge.conventions' version '0.0.7'
|
||||
id "com.gradle.enterprise" version "3.12.6"
|
||||
id "io.spring.ge.conventions" version "0.0.13"
|
||||
}
|
||||
|
||||
settings.gradle.projectsLoaded {
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
publishOnFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'spring-pulsar-dist'
|
||||
|
||||
include 'spring-pulsar'
|
||||
include 'spring-pulsar-cache-provider'
|
||||
include 'spring-pulsar-cache-provider-caffeine'
|
||||
@@ -38,3 +27,13 @@ include 'spring-pulsar-sample-apps:sample-pulsar-reader'
|
||||
include 'spring-pulsar-docs'
|
||||
include 'spring-pulsar-test'
|
||||
include 'integration-tests'
|
||||
|
||||
rootProject.name = "spring-pulsar-dist"
|
||||
|
||||
settings.gradle.projectsLoaded {
|
||||
gradleEnterprise {
|
||||
buildScan {
|
||||
publishOnFailure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,3 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging.showStandardStreams = true
|
||||
}
|
||||
|
||||
@@ -7,9 +7,4 @@ description = 'Spring Pulsar Cache Provider API'
|
||||
dependencies {
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging.showStandardStreams = true
|
||||
}
|
||||
|
||||
@@ -32,13 +32,8 @@ dependencies {
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.hamcrest:hamcrest'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter'
|
||||
testImplementation 'org.springframework:spring-test'
|
||||
testImplementation 'org.testcontainers:junit-jupiter'
|
||||
testImplementation 'org.testcontainers:pulsar'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging.showStandardStreams = true
|
||||
}
|
||||
|
||||
@@ -38,13 +38,8 @@ dependencies {
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testImplementation 'org.hamcrest:hamcrest'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
testImplementation 'org.mockito:mockito-junit-jupiter'
|
||||
testImplementation 'org.springframework:spring-test'
|
||||
// OutputCaptureExtension used by PulsarFunctionAdministrationTests
|
||||
testImplementation 'org.springframework.boot:spring-boot-test'
|
||||
}
|
||||
|
||||
test {
|
||||
testLogging.showStandardStreams = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user