|
| 1 | + |
| 2 | +buildscript { |
| 3 | + repositories { |
| 4 | + jcenter() |
| 5 | + } |
| 6 | + dependencies { |
| 7 | + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.5' |
| 8 | + } |
| 9 | +} |
| 10 | + |
| 11 | +apply plugin: 'groovy' |
| 12 | +apply plugin: 'maven' |
| 13 | +apply plugin: 'signing' |
| 14 | +apply plugin: 'eclipse' |
| 15 | +apply plugin: 'com.jfrog.bintray' |
| 16 | +apply plugin: 'maven-publish' |
| 17 | + |
| 18 | + |
| 19 | +repositories { |
| 20 | + jcenter() |
| 21 | +} |
| 22 | + |
| 23 | +group = 'org.standardout' |
| 24 | +version = '1.8.0-SNAPSHOT' |
| 25 | + |
| 26 | +sourceCompatibility = '1.7' |
| 27 | +targetCompatibility = '1.7' |
| 28 | + |
| 29 | +jar { |
| 30 | + // include license into jar |
| 31 | + into 'META-INF', { |
| 32 | + from 'LICENSE' |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +dependencies { |
| 37 | + compile gradleApi() |
| 38 | + compile 'biz.aQute.bnd:biz.aQute.bndlib:3.5.0' |
| 39 | + compile 'org.osgi:osgi.core:6.0.0' |
| 40 | + compile 'commons-io:commons-io:2.4' |
| 41 | + compile 'de.undercouch:gradle-download-task:3.1.1' |
| 42 | + compile localGroovy() |
| 43 | +} |
| 44 | + |
| 45 | +// package groovydoc into a jar file |
| 46 | +task packageJavadoc(type: Jar, dependsOn: 'groovydoc') { |
| 47 | + from groovydoc.destinationDir |
| 48 | + classifier = 'javadoc' |
| 49 | +} |
| 50 | + |
| 51 | +// package source into a jar file |
| 52 | +task packageSources(type: Jar) { |
| 53 | + from sourceSets.main.allSource |
| 54 | + classifier = 'sources' |
| 55 | +} |
| 56 | + |
| 57 | +// define artifacts for upload |
| 58 | +artifacts { |
| 59 | + archives jar |
| 60 | + archives packageJavadoc |
| 61 | + archives packageSources |
| 62 | +} |
| 63 | + |
| 64 | +def configurePom(def pom) { |
| 65 | + // ensure correct artifact ID |
| 66 | + pom.artifactId = 'bnd-platform' |
| 67 | + |
| 68 | + // pom file details |
| 69 | + pom.project { |
| 70 | + name 'bnd-platform' |
| 71 | + packaging 'jar' |
| 72 | + description 'Build OSGi bundles and Eclipse Update Sites from existing JARs, e.g. from Maven repositories (Plugin for Gradle)' |
| 73 | + url 'https://github.com/stempler/bnd-platform' |
| 74 | + |
| 75 | + scm { |
| 76 | + url 'scm:git:https://github.com/stempler/bnd-platform.git' |
| 77 | + connection 'scm:git:https://github.com/stempler/bnd-platform.git' |
| 78 | + developerConnection 'scm:git:https://github.com/stempler/bnd-platform.git' |
| 79 | + } |
| 80 | + |
| 81 | + licenses { |
| 82 | + license { |
| 83 | + name 'The Apache Software License, Version 2.0' |
| 84 | + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 85 | + distribution 'repo' |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + developers { |
| 90 | + developer { |
| 91 | + id 'stempler' |
| 92 | + name 'Simon Templer' |
| 93 | + email 'simon@templer.cc' |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +install { |
| 100 | + repositories.mavenInstaller { |
| 101 | + // ensure correct artifact ID when installing locally |
| 102 | + configurePom(pom) |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +// sign all artifacts |
| 107 | +signing { |
| 108 | + required { |
| 109 | + // NOTE: skipping does only work if no gradle properties specifying the key are present |
| 110 | + gradle.taskGraph.hasTask('uploadArchives') |
| 111 | + } |
| 112 | + sign configurations.archives |
| 113 | +} |
| 114 | + |
| 115 | +uploadArchives { |
| 116 | + repositories { |
| 117 | + mavenDeployer { |
| 118 | + // sign artifacts before upload |
| 119 | + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
| 120 | + |
| 121 | + // upload to sonatype OSS (snapshot/release) |
| 122 | + repository(url: this.version.endsWith('-SNAPSHOT') ? |
| 123 | + 'https://oss.sonatype.org/content/repositories/snapshots' : |
| 124 | + 'https://oss.sonatype.org/service/local/staging/deploy/maven2') { |
| 125 | + authentication(userName: this.hasProperty('sonatypeUsername') ? sonatypeUsername : '', |
| 126 | + password: this.hasProperty('sonatypePassword') ? sonatypePassword : '') |
| 127 | + } |
| 128 | + |
| 129 | + configurePom(pom) |
| 130 | + } |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +// groovydoc task work-around |
| 135 | + |
| 136 | +configurations { |
| 137 | + jansi.extendsFrom(runtime) |
| 138 | +} |
| 139 | +groovydoc { |
| 140 | + groovyClasspath = project.configurations.jansi |
| 141 | +} |
| 142 | +dependencies { |
| 143 | + jansi 'org.fusesource.jansi:jansi:1.11' |
| 144 | +} |
| 145 | + |
| 146 | +// bintray |
| 147 | + |
| 148 | +bintray { // task bintrayUpload |
| 149 | + user = project.getProperty('bintrayUser') |
| 150 | + key = project.getProperty('bintrayApiKey') |
| 151 | + |
| 152 | + configurations = ['archives'] |
| 153 | + |
| 154 | + dryRun = false |
| 155 | + publish = !project.version.endsWith('-SNAPSHOT') |
| 156 | + pkg { |
| 157 | + def githubUrl = 'https://github.com/stempler/bnd-platform' |
| 158 | + repo = 'gradle-plugins' |
| 159 | + name = 'bnd-platform' |
| 160 | + desc = 'Build OSGi bundles and p2 repositories / Eclipse Update Sites from existing libraries and their dependencies, e.g. from Maven repositories. Useful for instance for creating a target platform for Eclipse/Equinox or Maven Tycho build from third party dependencies.' |
| 161 | + websiteUrl = githubUrl |
| 162 | + issueTrackerUrl = "$githubUrl/issues" |
| 163 | + vcsUrl = "${githubUrl}.git" |
| 164 | + licenses = ['Apache-2.0'] |
| 165 | + labels = ['gradle', 'bnd', 'osgi', 'p2', 'eclipse', 'tycho'] |
| 166 | + publicDownloadNumbers = true |
| 167 | + // version descriptor |
| 168 | + version { |
| 169 | + name = project.version |
| 170 | + attributes = ['gradle-plugin': "org.standardout.bnd-platform:${project.group}:bnd-platform"] |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | +} |
| 175 | + |
| 176 | +publishing { |
| 177 | + publications { |
| 178 | + MyPublication(MavenPublication) { |
| 179 | + from components.java |
| 180 | + groupId "${group}" |
| 181 | + artifactId 'bnd-platform' |
| 182 | + version "${version}" |
| 183 | + } |
| 184 | + } |
| 185 | +} |
| 186 | + |
0 commit comments