|
| 1 | +/** |
| 2 | + * Gradle 1.5 build script. |
| 3 | + * |
| 4 | + * Custom gradle tasks: |
| 5 | + * zip - Builds the BeanIO zip distribution |
| 6 | + * site - Builds the BeanIO site distribution |
| 7 | + * |
| 8 | + * See the following URL for instructions regarding deployment to the Sonatype Maven repo: |
| 9 | + * https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide |
| 10 | + * |
| 11 | + * BeanIO 3.x and up is built using Java 8, with Java 7 source/target compatibility. |
| 12 | + * |
| 13 | + * To execute the 'uploadArchives' task, the following properties must be specified |
| 14 | + * in an external 'gradle.properties' file: |
| 15 | + * - (signing properties, see http://www.gradle.org/docs/current/userguide/signing_plugin.html) |
| 16 | + * - sonatypeUsername |
| 17 | + * - sonatypePassword |
| 18 | + */ |
| 19 | + |
| 20 | +apply plugin: 'java' |
| 21 | +apply plugin: 'groovy' |
| 22 | +apply plugin: 'maven' |
| 23 | +apply plugin: 'signing' |
| 24 | +// emma does not support Java 8 |
| 25 | +//apply from: 'https://raw.github.com/breskeby/gradleplugins/master/emmaPlugin/emma.gradle' |
| 26 | + |
| 27 | +version = "3.0.0.SNAPSHOT" |
| 28 | +group = "org.beanio" |
| 29 | +sourceCompatibility = 1.7 |
| 30 | +targetCompatibility = 1.7 |
| 31 | + |
| 32 | +ext.artifactId = "beanio" |
| 33 | +ext.isReleaseVersion = !version.endsWith("SNAPSHOT") |
| 34 | + |
| 35 | +repositories { |
| 36 | + mavenCentral() |
| 37 | +} |
| 38 | + |
| 39 | +configurations { |
| 40 | + jarjar |
| 41 | +} |
| 42 | + |
| 43 | +dependencies { |
| 44 | + testCompile group: 'junit', name: 'junit', version: '4.11' |
| 45 | + testCompile group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.9' |
| 46 | + testRuntime group: 'commons-logging', name: 'commons-logging', version: '1.1.2' |
| 47 | + //emma group: 'emma', name: 'emma', version: '2.0.5312' |
| 48 | + //emma group: 'emma', name: 'emma', version: '2.0.5312' |
| 49 | +} |
| 50 | + |
| 51 | +sourceSets { |
| 52 | + main { |
| 53 | + java { |
| 54 | + srcDir 'src' |
| 55 | + } |
| 56 | + resources { |
| 57 | + srcDir 'src' |
| 58 | + exclude '**/*.java' |
| 59 | + exclude '**/package.html' |
| 60 | + } |
| 61 | + } |
| 62 | + test { |
| 63 | + java { |
| 64 | + srcDir 'test' |
| 65 | + include '**/*.java' |
| 66 | + } |
| 67 | + groovy { |
| 68 | + srcDir 'test' |
| 69 | + include '**/*.groovy' |
| 70 | + } |
| 71 | + resources { |
| 72 | + srcDir 'test' |
| 73 | + exclude '**/*.java' |
| 74 | + exclude '**/*.groovy' |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +javadoc { |
| 80 | + options.header = "BeanIO $version" |
| 81 | + options.docTitle = "<h2>BeanIO 3.0 API</h2>" |
| 82 | + options.footer = "<i>Copyright © 2010-2014 Kevin Seim</i>" |
| 83 | + options.links = [ |
| 84 | + "http://download.oracle.com/javase/7/docs/api/" |
| 85 | + ] |
| 86 | +} |
| 87 | + |
| 88 | +jar { |
| 89 | + baseName = "$artifactId" |
| 90 | + includeEmptyDirs = false |
| 91 | + ext.metaInfDir = "$buildDir/tmp/jar" |
| 92 | + // create a list of exported packages for OSGi |
| 93 | + ant.dirset(id:"osgi.dirs", dir:"src/org/beanio", excludes: "xsd/**") |
| 94 | + ant.pathconvert(refid:"osgi.dirs", property:"osgi.packages", dirsep:".", pathsep:";version=\"${version}\",") { |
| 95 | + map(from:"$basedir/src/", to:"") |
| 96 | + } |
| 97 | + manifest { |
| 98 | + attributes( |
| 99 | + "Implementation-Title": "BeanIO ${version}", |
| 100 | + "Implementation-Version": version, |
| 101 | + "Bundle-ManifestVersion": "2", |
| 102 | + "Bundle-Name": "BeanIO", |
| 103 | + "Bundle-SymbolicName": "org.beanio", |
| 104 | + "Bundle-Version": version, |
| 105 | + "Bundle-Vendor": "Kevin Seim", |
| 106 | + "Bundle-Description": "BeanIO OSGi support", |
| 107 | + "Bundle-License": "http://www.apache.org/licenses/LICENSE-2.0", |
| 108 | + "Bundle-DocURL": "http://beanio.org", |
| 109 | + "Export-Package": ant.properties["osgi.packages"] + ";version=\"${version}\"", |
| 110 | + "DynamicImport-Package": "*") |
| 111 | + } |
| 112 | + doLast { |
| 113 | + manifest.writeTo("$metaInfDir/MANIFEST.MF") |
| 114 | + } |
| 115 | +} |
| 116 | + |
| 117 | +test { |
| 118 | + jvmArgs = ["-XX:-UseSplitVerifier"] |
| 119 | +} |
| 120 | + |
| 121 | +task sourcesJar(type: Jar, dependsOn:classes) { |
| 122 | + baseName = "$artifactId" |
| 123 | + classifier = 'sources' |
| 124 | + from("$projectDir/src") { |
| 125 | + exclude '**/package.html' |
| 126 | + } |
| 127 | + manifest { |
| 128 | + attributes( |
| 129 | + "Implementation-Title": "BeanIO ${version}", |
| 130 | + "Implementation-Version": version |
| 131 | + ) |
| 132 | + } |
| 133 | + metaInf { |
| 134 | + from("$projectDir") { |
| 135 | + include "LICENSE.txt" |
| 136 | + include "NOTICE.txt" |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | + |
| 141 | +task javadocJar(type: Jar, dependsOn:javadoc) { |
| 142 | + baseName = "$artifactId" |
| 143 | + classifier = 'javadoc' |
| 144 | + from javadoc.destinationDir |
| 145 | + manifest { |
| 146 | + attributes( |
| 147 | + "Implementation-Title": "BeanIO ${version}", |
| 148 | + "Implementation-Version": version |
| 149 | + ) |
| 150 | + } |
| 151 | + metaInf { |
| 152 | + from("$projectDir") { |
| 153 | + include "LICENSE.txt" |
| 154 | + include "NOTICE.txt" |
| 155 | + } |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +task zip(type: Zip, dependsOn: [javadoc, jar] ) { |
| 160 | + baseName = "$artifactId" |
| 161 | + from jar.archivePath |
| 162 | + from(javadoc.destinationDir) { |
| 163 | + into "docs/api" |
| 164 | + } |
| 165 | + from("$projectDir") { |
| 166 | + include "docs/**" |
| 167 | + include "src/**" |
| 168 | + include "test/**" |
| 169 | + include "*.txt" |
| 170 | + include "*.xml" |
| 171 | + include "*.properties" |
| 172 | + include "build.gradle" |
| 173 | + } |
| 174 | +} |
| 175 | + |
| 176 | +task site(type: Tar, dependsOn: javadoc) { |
| 177 | + baseName = "$artifactId" |
| 178 | + classifier "site" |
| 179 | + version "" |
| 180 | + compression Compression.GZIP |
| 181 | + from(javadoc.destinationDir) { |
| 182 | + into "3.0/docs/api" |
| 183 | + } |
| 184 | + from ("$projectDir/docs") { |
| 185 | + into "3.0/docs" |
| 186 | + } |
| 187 | + from("$projectDir/site") |
| 188 | + from("$projectDir/src/org/beanio/xsd") { |
| 189 | + include "2012/**" |
| 190 | + } |
| 191 | +} |
| 192 | + |
| 193 | +artifacts { |
| 194 | + archives jar |
| 195 | + archives sourcesJar |
| 196 | + archives javadocJar |
| 197 | +} |
| 198 | + |
| 199 | +signing { |
| 200 | + required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") } |
| 201 | + sign configurations.archives |
| 202 | +} |
| 203 | + |
| 204 | +uploadArchives { |
| 205 | + repositories { |
| 206 | + mavenDeployer { |
| 207 | + beforeDeployment { MavenDeployment deployment -> signPom(deployment) } |
| 208 | + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { |
| 209 | + authentication(userName: sonatypeUsername, password: sonatypePassword) |
| 210 | + } |
| 211 | + pom.project { |
| 212 | + name 'BeanIO' |
| 213 | + artifactId "$artifactId" |
| 214 | + packaging 'jar' |
| 215 | + description 'A Java un/marshalling library for CSV, XML, delimited and fixed length stream formats.' |
| 216 | + url 'http://beanio.org/' |
| 217 | + scm { |
| 218 | + url 'http://beanio.googlecode.com/svn' |
| 219 | + connection 'scm:svn:http://beanio.googlecode.com/svn/trunk' |
| 220 | + developerConnection 'scm:svn:https://beanio.googlecode.com/svn/trunk' |
| 221 | + } |
| 222 | + licenses { |
| 223 | + license { |
| 224 | + name 'The Apache Software License, Version 2.0' |
| 225 | + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 226 | + distribution 'repo' |
| 227 | + } |
| 228 | + } |
| 229 | + developers { |
| 230 | + developer { |
| 231 | + id 'kevinseim' |
| 232 | + name 'Kevin Seim' |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | + pom.whenConfigured { |
| 237 | + dependencies.find { dep -> dep.artifactId == 'commons-logging' }.optional = true |
| 238 | + } |
| 239 | + } |
| 240 | + } |
| 241 | +} |
0 commit comments