diff --git a/build.gradle b/build.gradle index 582f786e5e..e81b2acd3d 100644 --- a/build.gradle +++ b/build.gradle @@ -176,6 +176,7 @@ subprojects { project -> apply plugin: 'groovy' if (!isTestSuite) { apply plugin: 'maven-publish' + apply plugin: 'ivy-publish' apply plugin: 'signing' } apply plugin: 'eclipse' @@ -195,18 +196,29 @@ subprojects { project -> if (!isTestSuite) { publishing { + repositories { + ivy { + name = 'graceDist' + url = homeDistDir + patternLayout { + artifact '[artifact]-[revision](-[classifier])(.[ext])' + } + } + } publications { maven(MavenPublication) { from components.java - if (project.name != 'grace-gradle-plugin') { - pom.withXml { - def xml = asNode() + pom.withXml { + def xml = asNode() - xml.children().last() + pomInfo - } + xml.children().last() + pomInfo } } + + ivy(IvyPublication) { + from components.java + } } } @@ -258,7 +270,7 @@ subprojects { project -> toolVersion = checkstyleVersion configDirectory.set(rootProject.file("gradle/checkstyle")) } - + codenarc { toolVersion = codenarcVersion setConfigFile(new File("$rootDir/gradle/codenarc/codenarc.groovy")) @@ -384,24 +396,6 @@ subprojects { project -> exclude group: 'commons-logging', module: 'commons-logging' } } - - if (!isTestSuite) { - task installToHomeDist(type: org.grails.gradle.Upload) { - configuration = configurations.archives - repositories { - flatDir name: 'libs', dirs: distInstallDir - } - } - - project.tasks.withType(org.gradle.api.publish.maven.tasks.PublishToMavenLocal) { org.gradle.api.publish.maven.tasks.PublishToMavenLocal t -> - t.dependsOn installToHomeDist - t.doLast { - ant.copy(todir: homeDistDir, flatten: true, includeEmptyDirs: false) { - fileset dir: distInstallDir - } - } - } - } } task clean(type: Delete, group: 'build') { diff --git a/buildSrc/src/main/groovy/org/grails/gradle/Upload.java b/buildSrc/src/main/groovy/org/grails/gradle/Upload.java deleted file mode 100644 index fcafc3f9f1..0000000000 --- a/buildSrc/src/main/groovy/org/grails/gradle/Upload.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.grails.gradle; - -import java.io.File; -import java.util.List; - -import javax.annotation.Nullable; -import javax.inject.Inject; - -import groovy.lang.Closure; -import org.gradle.api.Action; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.PublishException; -import org.gradle.api.artifacts.dsl.RepositoryHandler; -import org.gradle.api.file.FileCollection; -import org.gradle.api.internal.ConventionTask; -import org.gradle.api.internal.artifacts.ArtifactPublicationServices; -import org.gradle.api.internal.artifacts.ArtifactPublisher; -import org.gradle.api.internal.artifacts.Module; -import org.gradle.api.internal.artifacts.configurations.ConfigurationInternal; -import org.gradle.api.internal.artifacts.repositories.PublicationAwareRepository; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.InputFiles; -import org.gradle.api.tasks.Internal; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskAction; -import org.gradle.internal.Transformers; -import org.gradle.internal.deprecation.DeprecationLogger; -import org.gradle.util.internal.ConfigureUtil; - -import static org.gradle.util.internal.CollectionUtils.collect; - -public class Upload extends ConventionTask { - - private Configuration configuration; - - private boolean uploadDescriptor; - - private File descriptorDestination; - - private RepositoryHandler repositories; - - @Inject - protected ArtifactPublicationServices getPublicationServices() { - throw new UnsupportedOperationException(); - } - - @TaskAction - protected void upload() { - getLogger().info("Publishing configuration: {}", configuration); - - Module module = ((ConfigurationInternal) configuration).getModule(); - - ArtifactPublisher artifactPublisher = getPublicationServices().createArtifactPublisher(); - File descriptorDestination = isUploadDescriptor() ? getDescriptorDestination() : null; - List publishRepositories = collect(getRepositories(), Transformers.cast(PublicationAwareRepository.class)); - - try { - artifactPublisher.publish(publishRepositories, module, configuration, descriptorDestination); - } - catch (Exception e) { - throw new PublishException(String.format("Could not publish configuration '%s'", configuration.getName()), e); - } - } - - /** - * Specifies whether the dependency descriptor should be uploaded. - */ - @Input - public boolean isUploadDescriptor() { - return uploadDescriptor; - } - - public void setUploadDescriptor(boolean uploadDescriptor) { - this.uploadDescriptor = uploadDescriptor; - } - - /** - * Returns the path to generate the dependency descriptor to. - */ - @Internal - public File getDescriptorDestination() { - return descriptorDestination; - } - - @SuppressWarnings("UnusedDeclaration") - public void setDescriptorDestination(File descriptorDestination) { - this.descriptorDestination = descriptorDestination; - } - - /** - * Returns the repositories to upload to. - */ - @Internal - public RepositoryHandler getRepositories() { - if (repositories == null) { - repositories = getPublicationServices().createRepositoryHandler(); - } - return repositories; - } - - /** - * Returns the configuration to upload. - */ - @Internal - public Configuration getConfiguration() { - return configuration; - } - - public void setConfiguration(Configuration configuration) { - this.configuration = configuration; - } - - /** - * Configures the set of repositories to upload to. - */ - public RepositoryHandler repositories(@Nullable Closure configureClosure) { - return ConfigureUtil.configure(configureClosure, getRepositories()); - } - - /** - * Configures the set of repositories to upload to. - * @since 3.5 - */ - public RepositoryHandler repositories(Action configureAction) { - RepositoryHandler repositories = getRepositories(); - configureAction.execute(repositories); - return repositories; - } - - /** - * Returns the artifacts which will be uploaded. - * - * @return the artifacts. - */ - @PathSensitive(PathSensitivity.NAME_ONLY) - @InputFiles - public FileCollection getArtifacts() { - Configuration configuration = getConfiguration(); - return configuration.getAllArtifacts().getFiles(); - } - -} diff --git a/grace-gradle-plugin/build.gradle b/grace-gradle-plugin/build.gradle index 54282f7fb7..19594ae2cf 100644 --- a/grace-gradle-plugin/build.gradle +++ b/grace-gradle-plugin/build.gradle @@ -41,6 +41,7 @@ dependencies { api gradleApi() api libs.maven.model api libs.spring.boot.gradle.plugin + api libs.spring.boot.loader.tools api libs.spring.dependency.management.plugin documentation libs.jansi @@ -151,17 +152,12 @@ publishing { pom { name = "Grace Gradle Plugin" description = "A Gradle plugin for Grace which provides a bunch of useful plugins" - } - } - } -} -project.afterEvaluate { - project.publishing.publications.each { MavenPublication publication-> - if (publication.name != "pluginMaven" || publication.name != "maven") { - publication.pom.withXml { - def xml = asNode() - xml.children().last() + pomInfo + withXml { + def xml = asNode() + + xml.children().last() + pomInfo + } } } } diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle index fe210a82d6..67a0cb9151 100644 --- a/gradle/assemble.gradle +++ b/gradle/assemble.gradle @@ -1,5 +1,3 @@ -import org.apache.tools.ant.filters.ReplaceTokens - apply plugin: org.grails.gradle.GrailsBuildPlugin def libsConfigurations = [] @@ -73,16 +71,7 @@ task populateDependencies(type: Sync, dependsOn: configurePopulateDependencies) includeEmptyDirs = false } -// Can't use sync task here because this directory contains other things as well. -task sourcesJars(type: Sync) { - into homeSrcDir - from subprojects.findAll { !it.name.startsWith('grace-test-suite') && !it.name.startsWith('grace-dependencies') && !it.name.startsWith('grace-bom') }.sourcesJar*.outputs*.files - - // sourcesFor comes from GrailsBuildPlugin - from { sourcesFor(libsConfigurations*.copyRecursive { it.name.startsWith('grace-datastore') }.collect { it.transitive = false; it }) } -} - -task grailsCreateStartScripts(type: GrailsCreateStartScripts) { +task grailsCreateStartScripts(type: GrailsCreateStartScripts, dependsOn: populateDependencies) { description = "Creates OS specific scripts to run grace-shell as a JVM application." mainClass = 'org.grails.cli.GrailsCli' applicationName = 'grace' @@ -126,7 +115,7 @@ class GrailsCreateStartScripts extends org.gradle.api.tasks.application.CreateSt } } -task install(dependsOn: [populateDependencies, grailsCreateStartScripts]) { task -> +task install(dependsOn: populateDependencies) { task -> subprojects { Project project -> if(!project.name.startsWith('grace-test-suite')) { task.dependsOn("$project.name:publishToMavenLocal") @@ -134,7 +123,28 @@ task install(dependsOn: [populateDependencies, grailsCreateStartScripts]) { task } } -task zipDist(type: Zip, dependsOn: [sourcesJars, install]) { +task publishToDist { task -> + subprojects { Project project -> + if (!project.name.startsWith('grace-test-suite') && !project.name.startsWith('grace-dependencies') && !project.name.startsWith('grace-bom')) { + if (project.name == 'grace-gradle-plugin') { + project.tasks.named("generateMetadataFileForIvyPublication").configure { + enabled = false + } + project.tasks.named("generateMetadataFileForPluginIvyPublication").configure { + enabled = false + } + task.dependsOn("$project.name:publishAllPublicationsToGraceDistRepository") + } else { + project.tasks.named("generateMetadataFileForIvyPublication").configure { + enabled = false + } + task.dependsOn("$project.name:publishAllPublicationsToGraceDistRepository") + } + } + } +} + +task zipDist(type: Zip, dependsOn: [install, publishToDist, grailsCreateStartScripts]) { destinationDirectory = "${buildDir}/distributions" as File archiveBaseName = 'grace' archiveAppendix = grailsVersion @@ -143,7 +153,7 @@ task zipDist(type: Zip, dependsOn: [sourcesJars, install]) { into("grace-$grailsVersion") { from(projectDir) { - include 'bin/grace', 'bin/grace.bat', 'lib/', 'media/', 'samples/', 'scripts/', 'LICENSE.txt', 'INSTALL.txt', "src/" + include 'bin/grace', 'bin/grace.bat', 'lib/', 'media/', 'samples/', 'scripts/', 'LICENSE.txt', 'INSTALL.txt' exclude 'ant/bin', 'src/grace', 'src/war' } from(docs.destinationDir) { @@ -156,20 +166,13 @@ task zipDist(type: Zip, dependsOn: [sourcesJars, install]) { into "dist" exclude "*.zip*" exclude "*.tar*" + exclude '*-javadoc.jar*', '*-sources.jar*', 'ivy-*' + } + from(homeDistDir) { + into "src" + include '*-sources.jar' } } } task assemble(dependsOn: zipDist) - -task publishToGrailsLocal { task -> - subprojects { Project project -> - if (!project.name.startsWith('grails-test-suite')) { - if (project.name == 'grails-gradle-plugin') { - task.dependsOn("$project.name:publishPluginMavenPublicationToGrailsLocalRepository") - } else { - task.dependsOn("$project.name:publishMavenPublicationToGrailsLocalRepository") - } - } - } -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c9616ce4bc..055310a8dc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -182,6 +182,7 @@ spring-boot-cli = { module = "org.springframework.boot:spring-boot-cli", version spring-boot-configurationProcessor = { module = "org.springframework.boot:spring-boot-configuration-processor", version.ref = "spring-boot" } spring-boot-dependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot" } spring-boot-gradle-plugin = { module = "org.springframework.boot:spring-boot-gradle-plugin", version.ref = "spring-boot" } +spring-boot-loader-tools = { module = "org.springframework.boot:spring-boot-loader-tools", version.ref = "spring-boot" } spring-boot-test = { module = "org.springframework.boot:spring-boot-test", version.ref = "spring-boot" } spring-context = { module = "org.springframework:spring-context", version.ref = "spring-framework" } spring-contextSupport = { module = "org.springframework:spring-context-support", version.ref = "spring-framework" }