Add configureDeployArtifactsTask(:Project) and skipProjectWithSonarQubePlugin(:Project) methods to io.spring.gradle.convention.Utils Groovy class.

This commit is contained in:
John Blum
2022-01-27 17:02:17 -08:00
parent c986789e87
commit 6652fdb793
4 changed files with 26 additions and 26 deletions

View File

@@ -33,29 +33,12 @@ class SpringModulePlugin extends AbstractSpringJavaPlugin {
@Override
void applyAdditionalPlugins(Project project) {
applyPlugins(project);
configureDeployArtifactsTask(project)
}
@SuppressWarnings("all")
private void applyPlugins(Project project) {
PluginManager pluginManager = project.getPluginManager();
pluginManager.apply(JavaLibraryPlugin.class)
pluginManager.apply(SpringMavenPlugin.class);
}
@SuppressWarnings("all")
private void configureDeployArtifactsTask(Project project) {
def deployArtifacts = project.task("deployArtifacts")
deployArtifacts.group = 'Deployments'
deployArtifacts.description = "Deploys project artifacts to either Artifactory or Maven Central"
if (!Utils.isRelease(project)) {
deployArtifacts.dependsOn project.tasks.artifactoryPublish
}
// TODO: Why?
Utils.configureDeployArtifactsTask(project)
}
}

View File

@@ -13,10 +13,9 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.spring.gradle.convention;
package io.spring.gradle.convention
import org.gradle.api.Project
import org.sonarqube.gradle.SonarQubePlugin;
/**
* Gradle Spring Java Plugin used to identify a Gradle {@link Project} as a {@literal Sample} and add configuration
@@ -30,8 +29,6 @@ class SpringSamplePlugin extends AbstractSpringJavaPlugin {
@Override
void applyAdditionalPlugins(Project project) {
project.plugins.withType(SonarQubePlugin) {
project.sonarqube.skipProject = true
}
Utils.skipProjectWithSonarQubePlugin(project)
}
}

View File

@@ -26,6 +26,6 @@ class SpringTestPlugin extends AbstractSpringJavaPlugin {
@Override
void applyAdditionalPlugins(Project project) {
project.sonarqube.skipProject = true
Utils.skipProjectWithSonarQubePlugin(project)
}
}

View File

@@ -15,7 +15,8 @@
*/
package io.spring.gradle.convention;
import org.gradle.api.Project;
import org.gradle.api.Project
import org.sonarqube.gradle.SonarQubePlugin;
/**
* Utility class encapsulating common operations on Gradle {@link Project Projects}.
@@ -56,7 +57,26 @@ class Utils {
return String.valueOf(project.getVersion());
}
static void configureDeployArtifactsTask(Project project) {
def deployArtifacts = project.task("deployArtifacts")
deployArtifacts.group = 'Deployments'
deployArtifacts.description = "Deploys project artifacts to either Artifactory or Maven Central"
if (!isRelease(project)) {
deployArtifacts.dependsOn project.tasks.artifactoryPublish
}
}
static String findPropertyAsString(Project project, String propertyName) {
return (String) project.findProperty(propertyName);
}
static void skipProjectWithSonarQubePlugin(Project project) {
project.plugins.withType(SonarQubePlugin) {
project.sonarqube.skipProject = true
}
}
}