|
| 1 | +description = 'Spring Integration MQTT Adapter' |
| 2 | + |
| 3 | +buildscript { |
| 4 | + repositories { |
| 5 | + maven { url 'https://repo.springsource.org/plugins-snapshot' } |
| 6 | + } |
| 7 | +} |
| 8 | + |
| 9 | +apply plugin: 'java' |
| 10 | +apply from: "${rootProject.projectDir}/publish-maven.gradle" |
| 11 | +apply plugin: 'eclipse' |
| 12 | +apply plugin: 'idea' |
| 13 | + |
| 14 | +group = 'org.springframework.integration.mqtt' |
| 15 | + |
| 16 | +repositories { |
| 17 | + maven { url 'http://repo.springsource.org/libs-snapshot' } |
| 18 | + maven { url 'http://repo.springsource.org/plugins-release' } |
| 19 | + mavenLocal() |
| 20 | +} |
| 21 | + |
| 22 | +sourceCompatibility=1.6 |
| 23 | +targetCompatibility=1.6 |
| 24 | + |
| 25 | +ext { |
| 26 | + junitVersion = '4.11' |
| 27 | + log4jVersion = '1.2.17' |
| 28 | + mockitoVersion = '1.9.5' |
| 29 | + springVersion = '3.1.3.RELEASE' |
| 30 | + springIntegrationVersion = '3.0.0.BUILD-SNAPSHOT' |
| 31 | + |
| 32 | + idPrefix = 'mqttadapter' |
| 33 | +} |
| 34 | + |
| 35 | +eclipse { |
| 36 | + project { |
| 37 | + natures += 'org.springframework.ide.eclipse.core.springnature' |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +sourceSets { |
| 42 | + test { |
| 43 | + resources { |
| 44 | + srcDirs = ['src/test/resources', 'src/test/java'] |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +// See http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:configurations |
| 50 | +// and http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ConfigurationContainer.html |
| 51 | +configurations { |
| 52 | + jacoco //Configuration Group used by Sonar to provide Code Coverage using JaCoCo |
| 53 | +} |
| 54 | + |
| 55 | +dependencies { |
| 56 | + compile "org.springframework.integration:spring-integration-core:$springIntegrationVersion" |
| 57 | + compile "org.eclipse.paho:MQTT-Java:3.0" |
| 58 | + testCompile "org.springframework.integration:spring-integration-test:$springIntegrationVersion" |
| 59 | + testCompile "junit:junit-dep:$junitVersion" |
| 60 | + testCompile "log4j:log4j:$log4jVersion" |
| 61 | + testCompile "org.mockito:mockito-all:$mockitoVersion" |
| 62 | + testCompile "org.springframework:spring-test:$springVersion" |
| 63 | + jacoco group: "org.jacoco", name: "org.jacoco.agent", version: "0.6.2.201302030002", classifier: "runtime" |
| 64 | +} |
| 65 | + |
| 66 | + |
| 67 | +// enable all compiler warnings; individual projects may customize further |
| 68 | +ext.xLintArg = '-Xlint:all' |
| 69 | +[compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg] |
| 70 | + |
| 71 | +test { |
| 72 | + // suppress all console output during testing unless running `gradle -i` |
| 73 | + logging.captureStandardOutput(LogLevel.INFO) |
| 74 | + jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=*" |
| 75 | +} |
| 76 | + |
| 77 | +task sourcesJar(type: Jar) { |
| 78 | + classifier = 'sources' |
| 79 | + from sourceSets.main.allJava |
| 80 | +} |
| 81 | + |
| 82 | +task javadocJar(type: Jar) { |
| 83 | + classifier = 'javadoc' |
| 84 | + from javadoc |
| 85 | +} |
| 86 | + |
| 87 | +artifacts { |
| 88 | + archives sourcesJar |
| 89 | + archives javadocJar |
| 90 | +} |
| 91 | + |
| 92 | +apply plugin: 'sonar' |
| 93 | + |
| 94 | +sonar { |
| 95 | + |
| 96 | + if (rootProject.hasProperty('sonarHostUrl')) { |
| 97 | + server.url = rootProject.sonarHostUrl |
| 98 | + } |
| 99 | + |
| 100 | + database { |
| 101 | + if (rootProject.hasProperty('sonarJdbcUrl')) { |
| 102 | + url = rootProject.sonarJdbcUrl |
| 103 | + } |
| 104 | + if (rootProject.hasProperty('sonarJdbcDriver')) { |
| 105 | + driverClassName = rootProject.sonarJdbcDriver |
| 106 | + } |
| 107 | + if (rootProject.hasProperty('sonarJdbcUsername')) { |
| 108 | + username = rootProject.sonarJdbcUsername |
| 109 | + } |
| 110 | + if (rootProject.hasProperty('sonarJdbcPassword')) { |
| 111 | + password = rootProject.sonarJdbcPassword |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + project { |
| 116 | + dynamicAnalysis = "reuseReports" |
| 117 | + withProjectProperties { props -> |
| 118 | + props["sonar.core.codeCoveragePlugin"] = "jacoco" |
| 119 | + props["sonar.jacoco.reportPath"] = "${buildDir.name}/jacoco.exec" |
| 120 | + } |
| 121 | + } |
| 122 | + |
| 123 | + logger.info("Sonar parameters used: server.url='${server.url}'; database.url='${database.url}'; database.driverClassName='${database.driverClassName}'; database.username='${database.username}'") |
| 124 | +} |
| 125 | + |
| 126 | +task api(type: Javadoc) { |
| 127 | + group = 'Documentation' |
| 128 | + description = 'Generates the Javadoc API documentation.' |
| 129 | + title = "${rootProject.description} ${version} API" |
| 130 | + options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED |
| 131 | + options.author = true |
| 132 | + options.header = rootProject.description |
| 133 | + options.overview = 'src/api/overview.html' |
| 134 | + |
| 135 | + source = sourceSets.main.allJava |
| 136 | + classpath = project.sourceSets.main.compileClasspath |
| 137 | + destinationDir = new File(buildDir, "api") |
| 138 | +} |
| 139 | + |
| 140 | +task schemaZip(type: Zip) { |
| 141 | + group = 'Distribution' |
| 142 | + classifier = 'schema' |
| 143 | + description = "Builds -${classifier} archive containing all " + |
| 144 | + "XSDs for deployment at static.springframework.org/schema." |
| 145 | + |
| 146 | + def Properties schemas = new Properties(); |
| 147 | + def shortName = idPrefix.replaceFirst("${idPrefix}-", '') |
| 148 | + |
| 149 | + project.sourceSets.main.resources.find { |
| 150 | + it.path.endsWith('META-INF/spring.schemas') |
| 151 | + }?.withInputStream { schemas.load(it) } |
| 152 | + |
| 153 | + for (def key : schemas.keySet()) { |
| 154 | + File xsdFile = project.sourceSets.main.resources.find { |
| 155 | + it.path.endsWith(schemas.get(key)) |
| 156 | + } |
| 157 | + assert xsdFile != null |
| 158 | + into ("integration/${shortName}") { |
| 159 | + from xsdFile.path |
| 160 | + } |
| 161 | + } |
| 162 | + |
| 163 | +} |
| 164 | + |
| 165 | +task docsZip(type: Zip) { |
| 166 | + group = 'Distribution' |
| 167 | + classifier = 'docs' |
| 168 | + description = "Builds -${classifier} archive containing the api " + |
| 169 | + "for deployment at static.springframework.org/spring-integration/docs." |
| 170 | + |
| 171 | + from('src/dist') { |
| 172 | + include 'changelog.txt' |
| 173 | + } |
| 174 | + |
| 175 | + from (api) { |
| 176 | + into 'api' |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) { |
| 181 | + group = 'Distribution' |
| 182 | + classifier = 'dist' |
| 183 | + description = "Builds -${classifier} archive, containing all jars and docs, " + |
| 184 | + "suitable for community download page." |
| 185 | + |
| 186 | + ext.baseDir = "${project.name}-${project.version}"; |
| 187 | + |
| 188 | + from('src/dist') { |
| 189 | + include 'readme.txt' |
| 190 | + include 'license.txt' |
| 191 | + include 'notice.txt' |
| 192 | + into "${baseDir}" |
| 193 | + } |
| 194 | + |
| 195 | + from(zipTree(docsZip.archivePath)) { |
| 196 | + into "${baseDir}/docs" |
| 197 | + } |
| 198 | + |
| 199 | + from(zipTree(schemaZip.archivePath)) { |
| 200 | + into "${baseDir}/schema" |
| 201 | + } |
| 202 | + |
| 203 | + into ("${baseDir}/libs") { |
| 204 | + from project.jar |
| 205 | + from project.sourcesJar |
| 206 | + from project.javadocJar |
| 207 | + } |
| 208 | +} |
| 209 | + |
| 210 | +// Create an optional "with dependencies" distribution. |
| 211 | +// Not published by default; only for use when building from source. |
| 212 | +task depsZip(type: Zip, dependsOn: distZip) { zipTask -> |
| 213 | + group = 'Distribution' |
| 214 | + classifier = 'dist-with-deps' |
| 215 | + description = "Builds -${classifier} archive, containing everything " + |
| 216 | + "in the -${distZip.classifier} archive plus all dependencies." |
| 217 | + |
| 218 | + from zipTree(distZip.archivePath) |
| 219 | + |
| 220 | + gradle.taskGraph.whenReady { taskGraph -> |
| 221 | + if (taskGraph.hasTask(":${zipTask.name}")) { |
| 222 | + def projectName = rootProject.name |
| 223 | + def artifacts = new HashSet() |
| 224 | + |
| 225 | + rootProject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { artifact -> |
| 226 | + def dependency = artifact.moduleVersion.id |
| 227 | + if (!projectName.equals(dependency.name)) { |
| 228 | + artifacts << artifact.file |
| 229 | + } |
| 230 | + } |
| 231 | + |
| 232 | + zipTask.from(artifacts) { |
| 233 | + into "${distZip.baseDir}/deps" |
| 234 | + } |
| 235 | + } |
| 236 | + } |
| 237 | +} |
| 238 | + |
| 239 | +artifacts { |
| 240 | + archives distZip |
| 241 | + archives docsZip |
| 242 | + archives schemaZip |
| 243 | +} |
| 244 | + |
| 245 | +task dist(dependsOn: assemble) { |
| 246 | + group = 'Distribution' |
| 247 | + description = 'Builds -dist, -docs and -schema distribution archives.' |
| 248 | +} |
| 249 | + |
| 250 | +task wrapper(type: Wrapper) { |
| 251 | + description = 'Generates gradlew[.bat] scripts' |
| 252 | + gradleVersion = '1.6' |
| 253 | +} |
0 commit comments