Use local Spring PropDepsPlugin Gradle Pugins.
This commit is contained in:
@@ -19,6 +19,19 @@ repositories {
|
||||
maven { url 'https://repo.spring.io/plugins-release/' }
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
managementConfiguration {
|
||||
id = "io.spring.convention.management-configuration"
|
||||
implementationClass = "io.spring.gradle.convention.ManagementConfigurationPlugin"
|
||||
}
|
||||
propdeps {
|
||||
id = "org.springframework.propdeps"
|
||||
implementationClass = "org.springframework.gradle.propdeps.PropDepsPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
implementation {
|
||||
exclude module: 'groovy-all'
|
||||
@@ -33,7 +46,6 @@ dependencies {
|
||||
implementation 'gradle.plugin.org.gretty:gretty:3.0.1'
|
||||
implementation 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1'
|
||||
implementation 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE'
|
||||
implementation 'io.spring.gradle:propdeps-plugin:0.0.10.RELEASE'
|
||||
implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15'
|
||||
implementation 'io.spring.nohttp:nohttp-gradle:0.0.3.RELEASE'
|
||||
implementation 'org.asciidoctor:asciidoctor-gradle-jvm:3.1.0'
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2017-present 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 io.spring.gradle.propdeps
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.plugins.ide.eclipse.EclipsePlugin
|
||||
|
||||
/**
|
||||
* Gradle {@link Plugin} to allow {@literal optional} and {@literal provided} dependency configurations
|
||||
* to work with the standard Gradle {@link EclipsePlugin}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author John Blum
|
||||
* @see org.gradle.api.Plugin
|
||||
* @see org.gradle.api.Project
|
||||
* @see org.gradle.plugins.ide.eclipse.EclipsePlugin
|
||||
*/
|
||||
class PropDepsEclipsePlugin implements Plugin<Project> {
|
||||
|
||||
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,48 @@
|
||||
/*
|
||||
* Copyright 2017-present 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 io.spring.gradle.propdeps
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.plugins.ide.idea.IdeaPlugin
|
||||
|
||||
/**
|
||||
* Gradle {@link Plugin} to allow {@literal optional} and {@literal provided} dependency configurations
|
||||
* to work with the standard Gradle {@link IdeaPlugin}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Brian Clozel
|
||||
* @author John Blum
|
||||
* @see org.gradle.api.Plugin
|
||||
* @see org.gradle.api.Project
|
||||
* @see org.gradle.plugins.ide.idea.IdeaPlugin
|
||||
* @link https://youtrack.jetbrains.com/issue/IDEA-107046
|
||||
* @link https://youtrack.jetbrains.com/issue/IDEA-117668
|
||||
*/
|
||||
class PropDepsIdeaPlugin implements Plugin<Project> {
|
||||
|
||||
void apply(Project project) {
|
||||
|
||||
project.plugins.apply(PropDepsPlugin)
|
||||
project.plugins.apply(IdeaPlugin)
|
||||
project.idea.module {
|
||||
// IntelliJ 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,66 @@
|
||||
/*
|
||||
* Copyright 2002-2012 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package io.spring.gradle.propdeps
|
||||
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.maven.Conf2ScopeMappingContainer
|
||||
import org.gradle.api.artifacts.maven.MavenPom
|
||||
import org.gradle.api.artifacts.maven.PomFilterContainer
|
||||
import org.gradle.api.plugins.MavenPlugin
|
||||
import org.gradle.api.tasks.*
|
||||
|
||||
|
||||
/**
|
||||
* Plugin to allow optional and provided dependency configurations to work with the
|
||||
* standard gradle 'maven' plugin
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class PropDepsMavenPlugin implements Plugin<Project> {
|
||||
|
||||
public void apply(Project project) {
|
||||
project.plugins.apply(PropDepsPlugin)
|
||||
project.plugins.apply(MavenPlugin)
|
||||
|
||||
Conf2ScopeMappingContainer scopeMappings = project.conf2ScopeMappings
|
||||
scopeMappings.addMapping(MavenPlugin.COMPILE_PRIORITY + 1,
|
||||
project.configurations.getByName("provided"), Conf2ScopeMappingContainer.PROVIDED)
|
||||
|
||||
// Add a temporary new optional scope
|
||||
scopeMappings.addMapping(MavenPlugin.COMPILE_PRIORITY + 2,
|
||||
project.configurations.getByName("optional"), "optional")
|
||||
|
||||
// Add a hook to replace the optional scope
|
||||
project.afterEvaluate {
|
||||
project.tasks.withType(Upload).each { applyToUploadTask(project, it) }
|
||||
}
|
||||
}
|
||||
|
||||
private void applyToUploadTask(Project project, Upload upload) {
|
||||
upload.repositories.withType(PomFilterContainer).each{ applyToPom(project, it) }
|
||||
}
|
||||
|
||||
private void applyToPom(Project project, PomFilterContainer pomContainer) {
|
||||
pomContainer.pom.whenConfigured { MavenPom pom ->
|
||||
pom.dependencies.findAll{ it.scope == "optional" }.each {
|
||||
it.scope = "compile"
|
||||
it.optional = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2017-present 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 io.spring.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
|
||||
|
||||
/**
|
||||
* Gradle {@link Plugin} to allow {@literal optional} and {@literal provided} dependency configurations.
|
||||
*
|
||||
* As stated in the Maven documentation, {@literal provided} scope {@literal "is only available on the compilation
|
||||
* and test classpath, and is not transitive"}.
|
||||
*
|
||||
* This {@link 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
|
||||
* @author John Blum
|
||||
*
|
||||
* @see org.gradle.api.Plugin
|
||||
* @see org.gradle.api.Project
|
||||
* @see PropDepsEclipsePlugin
|
||||
* @see PropDepsIdeaPlugin
|
||||
* @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>
|
||||
*/
|
||||
class PropDepsPlugin implements Plugin<Project> {
|
||||
|
||||
void apply(Project project) {
|
||||
|
||||
project.plugins.apply(JavaPlugin)
|
||||
|
||||
Configuration optional = addConfiguration(project, "optional")
|
||||
Configuration provided = addConfiguration(project, "provided")
|
||||
|
||||
Javadoc javadoc = project.tasks.getByName(JavaPlugin.JAVADOC_TASK_NAME)
|
||||
|
||||
javadoc.classpath = javadoc.classpath + provided + 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user