47 changed files with 218 additions and 163 deletions
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip |
||||
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
||||
|
||||
@ -1,59 +0,0 @@
@@ -1,59 +0,0 @@
|
||||
package io.spring.gradle.convention; |
||||
|
||||
|
||||
import io.spring.gradle.propdeps.PropDepsPlugin; |
||||
import org.gradle.api.Plugin; |
||||
import org.gradle.api.Project; |
||||
import org.gradle.api.artifacts.ConfigurationContainer; |
||||
import org.gradle.api.plugins.JavaPlugin; |
||||
import org.gradle.api.plugins.JavaTestFixturesPlugin; |
||||
import org.gradle.api.plugins.PluginContainer; |
||||
import org.gradle.api.publish.PublishingExtension; |
||||
import org.gradle.api.publish.maven.MavenPublication; |
||||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; |
||||
|
||||
/** |
||||
* Creates a Management configuration that is appropriate for adding a platform to that is not exposed externally. If |
||||
* the JavaPlugin is applied, the compileClasspath, runtimeClasspath, testCompileClasspath, and testRuntimeClasspath |
||||
* will extend from it. |
||||
* @author Rob Winch |
||||
*/ |
||||
public class ManagementConfigurationPlugin implements Plugin<Project> { |
||||
|
||||
public static final String MANAGEMENT_CONFIGURATION_NAME = "management"; |
||||
|
||||
@Override |
||||
public void apply(Project project) { |
||||
ConfigurationContainer configurations = project.getConfigurations(); |
||||
configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> { |
||||
management.setVisible(false); |
||||
management.setCanBeConsumed(false); |
||||
management.setCanBeResolved(false); |
||||
|
||||
PluginContainer plugins = project.getPlugins(); |
||||
plugins.withType(JavaPlugin.class, (javaPlugin) -> { |
||||
configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); |
||||
configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); |
||||
configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); |
||||
configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); |
||||
}); |
||||
plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> { |
||||
configurations.getByName("testFixturesCompileClasspath").extendsFrom(management); |
||||
configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management); |
||||
}); |
||||
plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> { |
||||
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); |
||||
publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> { |
||||
mavenPublication.versionMapping((versions) -> |
||||
versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()) |
||||
); |
||||
})); |
||||
}); |
||||
plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> { |
||||
configurations.getByName("optional").extendsFrom(management); |
||||
configurations.getByName("provided").extendsFrom(management); |
||||
})); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
@ -1,26 +0,0 @@
@@ -1,26 +0,0 @@
|
||||
package io.spring.gradle.convention |
||||
|
||||
import org.gradle.api.Plugin |
||||
import org.gradle.api.Project |
||||
|
||||
public class OssrhPlugin implements Plugin<Project> { |
||||
|
||||
@Override |
||||
public void apply(Project project) { |
||||
if(project.hasProperty('ossrhUsername')) { |
||||
project.uploadArchives { |
||||
repositories { |
||||
mavenDeployer { |
||||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { |
||||
authentication(userName: project.ossrhUsername, password: project.ossrhPassword) |
||||
} |
||||
|
||||
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { |
||||
authentication(userName: project.ossrhUsername, password: project.ossrhPassword) |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/* |
||||
* Copyright 2002-2021 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.gradle.propdeps |
||||
|
||||
|
||||
import org.gradle.api.Plugin |
||||
import org.gradle.api.Project |
||||
import org.gradle.plugins.ide.eclipse.EclipsePlugin |
||||
|
||||
/** |
||||
* Plugin to allow optional and provided dependency configurations to work with the |
||||
* standard gradle 'eclipse' plugin |
||||
* |
||||
* @author Phillip Webb |
||||
*/ |
||||
class PropDepsEclipsePlugin implements Plugin<Project> { |
||||
|
||||
public void apply(Project project) { |
||||
project.plugins.apply(PropDepsPlugin) |
||||
project.plugins.apply(EclipsePlugin) |
||||
|
||||
project.eclipse { |
||||
classpath { |
||||
plusConfigurations += [project.configurations.provided, project.configurations.optional] |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
/* |
||||
* Copyright 2002-2021 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.gradle.propdeps |
||||
|
||||
|
||||
import org.gradle.api.Plugin |
||||
import org.gradle.api.Project |
||||
import org.gradle.plugins.ide.idea.IdeaPlugin |
||||
|
||||
/** |
||||
* Plugin to allow optional and provided dependency configurations to work with the |
||||
* standard gradle 'idea' plugin |
||||
* |
||||
* @author Phillip Webb |
||||
* @author Brian Clozel |
||||
* @link https://youtrack.jetbrains.com/issue/IDEA-107046 |
||||
* @link https://youtrack.jetbrains.com/issue/IDEA-117668 |
||||
*/ |
||||
class PropDepsIdeaPlugin implements Plugin<Project> { |
||||
|
||||
public void apply(Project project) { |
||||
project.plugins.apply(PropDepsPlugin) |
||||
project.plugins.apply(IdeaPlugin) |
||||
project.idea.module { |
||||
// IDEA internally deals with 4 scopes : COMPILE, TEST, PROVIDED, RUNTIME |
||||
// but only PROVIDED seems to be picked up |
||||
scopes.PROVIDED.plus += [project.configurations.provided] |
||||
scopes.PROVIDED.plus += [project.configurations.optional] |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
/* |
||||
* Copyright 2002-2021 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.gradle.propdeps |
||||
|
||||
|
||||
import org.gradle.api.Plugin |
||||
import org.gradle.api.Project |
||||
import org.gradle.api.artifacts.Configuration |
||||
import org.gradle.api.plugins.JavaLibraryPlugin |
||||
import org.gradle.api.plugins.JavaPlugin |
||||
import org.gradle.api.tasks.javadoc.Javadoc |
||||
|
||||
/** |
||||
* Plugin to allow 'optional' and 'provided' dependency configurations |
||||
* |
||||
* As stated in the maven documentation, provided scope "is only available on the compilation and test classpath, |
||||
* and is not transitive". |
||||
* |
||||
* This plugin creates two new configurations, and each one: |
||||
* <ul> |
||||
* <li>is a parent of the compile configuration</li> |
||||
* <li>is not visible, not transitive</li> |
||||
* <li>all dependencies are excluded from the default configuration</li> |
||||
* </ul> |
||||
* |
||||
* @author Phillip Webb |
||||
* @author Brian Clozel |
||||
* @author Rob Winch |
||||
* |
||||
* @see <a href="https://www.gradle.org/docs/current/userguide/java_plugin.html#N121CF">Maven documentation</a> |
||||
* @see <a href="https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope">Gradle configurations</a> |
||||
* @see PropDepsEclipsePlugin |
||||
* @see PropDepsIdeaPlugin |
||||
*/ |
||||
class PropDepsPlugin implements Plugin<Project> { |
||||
|
||||
public void apply(Project project) { |
||||
project.plugins.apply(JavaPlugin) |
||||
|
||||
Configuration provided = addConfiguration(project, "provided") |
||||
Configuration optional = addConfiguration(project, "optional") |
||||
|
||||
Javadoc javadoc = project.tasks.getByName(JavaPlugin.JAVADOC_TASK_NAME) |
||||
javadoc.classpath = javadoc.classpath.plus(provided).plus(optional) |
||||
} |
||||
|
||||
private Configuration addConfiguration(Project project, String name) { |
||||
Configuration configuration = project.configurations.create(name) |
||||
configuration.extendsFrom(project.configurations.implementation) |
||||
project.plugins.withType(JavaLibraryPlugin, { |
||||
configuration.extendsFrom(project.configurations.api) |
||||
}) |
||||
|
||||
project.sourceSets.all { |
||||
compileClasspath += configuration |
||||
runtimeClasspath += configuration |
||||
} |
||||
|
||||
return configuration |
||||
} |
||||
|
||||
} |
||||
@ -1 +0,0 @@
@@ -1 +0,0 @@
|
||||
implementation-class=io.spring.gradle.convention.OssrhPlugin |
||||
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME |
||||
distributionPath=wrapper/dists |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip |
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip |
||||
zipStoreBase=GRADLE_USER_HOME |
||||
zipStorePath=wrapper/dists |
||||
|
||||
Loading…
Reference in new issue