diff --git a/.gitignore b/.gitignore index 66bb817bf3..0ba3856cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ pom.xml si.java.hsp spring-integration-jms/activemq-data/ spring-integration-samples/loanshark/application.log* +target diff --git a/build.gradle b/build.gradle index 50171b85e7..73f221658b 100644 --- a/build.gradle +++ b/build.gradle @@ -263,6 +263,7 @@ project('spring-integration-jms') { description = 'Spring Integration JMS Support' dependencies { compile project(":spring-integration-core") + compile "org.springframework:spring-context:$springVersion" compile "org.springframework:spring-jms:$springVersion" compile "org.springframework:spring-tx:$springVersion" compile ("org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1") { provided = true } @@ -416,6 +417,8 @@ apply from: "$rootDir/gradle/dist.gradle" // add tasks like 'snapshotDependencyCheck' apply from: "${rootDir}/gradle/checks.gradle" +// add 'generatePom' task to generate root pom with section +apply from: "$rootDir/gradle/maven-root-pom.gradle" // ----------------------------------------------------------------------------- // Import tasks related to releasing and managing the project diff --git a/gradle/maven-deployment.gradle b/gradle/maven-deployment.gradle index 1da52540f6..d588d0ba56 100644 --- a/gradle/maven-deployment.gradle +++ b/gradle/maven-deployment.gradle @@ -123,6 +123,7 @@ uploadArchives { configurePom(deployer.pom) } + /** * Install gradle-built artifacts to the local m2 maven cache. * Further customizes the 'install' task contributed by the 'maven' plugin. @@ -134,6 +135,105 @@ install { configurePom(repositories.mavenInstaller.pom) } + +/** + * Generate a Maven pom.xml for use at build time. Dependency information will + * be based on Gradle metadata for the project, and other customizations such + * as licensing information and source compatibility settings are configured + * within. + * + * @author Chris Beams + * @see http://gradle.org/0.9-preview-3/docs/userguide/userguide_single.html#pomBuilder + */ +task generatePom { + group = 'Build' + description = 'Generates a Maven POM file suitable for use in building the project' + + generatedPomFileName = "pom.xml" + + // enable partial cleaning with `gradle cleanGeneratePom` + outputs.files(generatedPomFileName) + + doLast() { + // customize the pom creation process + p = pom { + project { + name = project.description + properties { + setProperty('project.build.sourceEncoding', 'UTF8') + } + build { + plugins { + plugin { + groupId = 'org.apache.maven.plugins' + artifactId = 'maven-compiler-plugin' + configuration { + source = '1.5' + target = '1.5' + } + } + plugin { + groupId = 'org.apache.maven.plugins' + artifactId = 'maven-surefire-plugin' + configuration { + includes { + include = '**/*Tests.java' + } + excludes { + exclude = '**/*Abstract*.java' + } + } + } + } + resources { + resource { + directory = 'src/main/java' + includes = ['**/*'] + excludes = ['**/*.java'] + } + resource { + directory = 'src/main/resources' + includes = ['**/*'] + } + } + testResources { + testResource { + directory = 'src/test/java' + includes = ['**/*'] + excludes = ['**/*.java'] + } + testResource { + directory = 'src/test/resources' + includes = ['**/*'] + } + } + } + } + } + + // customizing the artifact id is a special case that must be configured + // after the pom is fully configured, otherwise it'll be overwritten + p.whenConfigured { pom -> pom.artifactId = project.name } + + configurePom(p) + + // write the pom.xml file out to the filesystem + p.writeTo(generatedPomFileName) + } + + // ensure that pom generation happens every time resources are processed + // (which practically means any time a build happens). if the dependencies + // for the project have been updated (in $rootDir/build.gradle), the pom + // will have diffs in it and the developer will be reminded to check in + // the change during the next commit cycle. + //processResources.dependsOn generatePom +} + + +/** + * Read dynamic 'optional' and 'provided' properties from gradle dependencies + * and translate them to their maven POM equivalents. + */ def configurePom(def pom) { pom.whenConfigured { generatedPom -> def optionalDeps = configurations.testRuntime.allDependencies.findAll { gradleDep -> diff --git a/gradle/maven-root-pom.gradle b/gradle/maven-root-pom.gradle new file mode 100644 index 0000000000..d26f1402ec --- /dev/null +++ b/gradle/maven-root-pom.gradle @@ -0,0 +1,62 @@ + +/* + * Copyright 2002-2010 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. + */ + +/** + * Generate a root Maven pom.xml for use at build time. Contains nothing other + * than a 'modules' section aggregating child projects. This pom will never be + * installed locally or deployed remotely. Child projects will not explicitly + * declare this pom as their parent, given than nothing need be inherited from + * it. + * + * @author Chris Beams + * @see maven-deployment.gradle for per-project generatePom task + */ +task generatePom { + apply plugin: 'maven' + group = 'Build' + description = 'Generates a root Maven pom for convenience.' + + generatedPomFileName = "pom.xml" + + // enable partial cleaning with `gradle cleanGeneratePom` + outputs.files(generatedPomFileName) + + doLast() { + // customize the pom creation process + p = pom { + project { + name = project.description + packaging = 'pom' + modules = javaprojects.collect { project -> project.name } + } + } + + // customizing the artifact id is a special case that must be configured + // after the pom is fully configured, otherwise it'll be overwritten + p.whenConfigured { pom -> pom.artifactId = project.name } + + // write the pom.xml file out to the filesystem + p.writeTo(generatedPomFileName) + } + + // ensure that pom generation happens every time resources are processed + // (which practically means any time a build happens). if the dependencies + // for the project have been updated (in $rootDir/build.gradle), the pom + // will have diffs in it and the developer will be reminded to check in + // the change during the next commit cycle. + //processResources.dependsOn generatePom +}