Skip to content

Commit

Permalink
allow jgiven-android to be published
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schäfer committed Dec 24, 2016
1 parent 40b35f7 commit 41145fc
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 113 deletions.
229 changes: 117 additions & 112 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,121 @@ subprojects{
}
}

configure(subprojects.findAll {!it.name.contains("android")}) {
apply plugin: 'checkstyle'
configure(subprojects) {
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'maven-publish'

description "${rootProject.description} - Module ${project.name}"
sourceCompatibility = targetCompatibility = 1.6

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
signing {
// requires gradle.properties, see http://www.gradle.org/docs/current/userguide/signing_plugin.html
required {
isReleaseVersion && gradle.taskGraph.hasTask('uploadArchives')
}
sign configurations.archives
}

ext {
sonatypeUsername = (rootProject.hasProperty('sonatypeUsername')) ?
rootProject.sonatypeUsername :
"$System.env.SONATYPE_USERNAME"

sonatypePassword = (rootProject.hasProperty('sonatypePassword')) ?
rootProject.sonatypePassword :
"$System.env.SONATYPE_PASSWORD"
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment ->
signing.signPom(deployment)
}
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
// username and password from gradle.properties
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom {
project {
name project.name
url 'http://jgiven.org'

scm {
url 'scm:[email protected]:TNG/jgiven.git'
connection 'scm:[email protected]:TNG/jgiven.git'
developerConnection 'scm:[email protected]:TNG/jgiven.git'
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

developers {
developer {
id 'janschaefer'
name 'Jan Schäfer'
}
}
}
whenConfigured { pom ->
def junitDep = pom.dependencies.find { dep -> dep.groupId == 'junit' && dep.artifactId == 'junit' }
if (junitDep != null) {
junitDep.with {
version = '[4.9,4.12]'
scope = 'provided'
}
}
pom.dependencies.removeAll(pom.dependencies.findAll { dep -> dep.scope in ['test'] })
}
}
}
}
}

// to be able use project.description which may be overridden in later executed build.gradle of subproject
project.afterEvaluate {
uploadArchives.repositories {
mavenDeployer.pom.project {
description = project.description
}
}
}

uploadArchives.onlyIf {
!(isCI && isReleaseVersion)
}

uploadArchives.doFirst {
if (!isCI && isReleaseVersion && !JavaVersion.current().isJava8Compatible()) {
throw new GradleException("Releases have to be done with Java 8");
}
}

idea {
module {
downloadSources = true
downloadJavadoc = true
}
}

}

configure(subprojects.findAll {!it.name.contains("android")}) {
apply plugin: 'checkstyle'
apply plugin: 'java'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'ru.vyarus.animalsniffer'

dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion

Expand All @@ -107,8 +200,17 @@ configure(subprojects.findAll {!it.name.contains("android")}) {
signature 'org.codehaus.mojo.signature:java16:1.1@signature'
}

sourceCompatibility = targetCompatibility = 1.6

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}

tasks.withType(JavaCompile) {
// needed for DeSzenarioTest.java as it has Umlauts in the code
options.encoding = 'UTF-8'
}

Expand Down Expand Up @@ -141,7 +243,6 @@ configure(subprojects.findAll {!it.name.contains("android")}) {
artifacts {
archives jar
archives javadocJar

archives sourcesJar
}

Expand Down Expand Up @@ -174,6 +275,10 @@ configure(subprojects.findAll {!it.name.contains("android")}) {
exclude '**/impl/**'
}

javadoc.onlyIf {
JavaVersion.current().isJava8Compatible()
}

checkstyle {
configFile = file("${rootProject.projectDir}/develop/checkstyle-rules.xml")
showViolations = false
Expand Down Expand Up @@ -213,106 +318,6 @@ configure(subprojects.findAll {!it.name.contains("android")}) {

copyAsciiDoc.finalizedBy(asciidoctor)

// -- build and publish artifacts -------------------------------------------------------------------------------------

signing {
// requires gradle.properties, see http://www.gradle.org/docs/current/userguide/signing_plugin.html
required {
isReleaseVersion && gradle.taskGraph.hasTask('uploadArchives')
}
sign configurations.archives
}

ext {
sonatypeUsername = (rootProject.hasProperty('sonatypeUsername')) ?
rootProject.sonatypeUsername :
"$System.env.SONATYPE_USERNAME"

sonatypePassword = (rootProject.hasProperty('sonatypePassword')) ?
rootProject.sonatypePassword :
"$System.env.SONATYPE_PASSWORD"
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment ->
signing.signPom(deployment)
}
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
// username and password from gradle.properties
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom {
project {
name project.name
url 'http://jgiven.org'

scm {
url 'scm:[email protected]:TNG/jgiven.git'
connection 'scm:[email protected]:TNG/jgiven.git'
developerConnection 'scm:[email protected]:TNG/jgiven.git'
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

developers {
developer {
id 'janschaefer'
name 'Jan Schäfer'
}
}
}
whenConfigured { pom ->
pom.dependencies.find { dep -> dep.groupId == 'junit' && dep.artifactId == 'junit' }.with {
version = '[4.9,4.12]'
scope = 'provided'
}
pom.dependencies.removeAll(pom.dependencies.findAll { dep -> dep.scope in ['test'] })
}
}
}
}
}

// to be able use project.description which may be overridden in later executed build.gradle of subproject
project.afterEvaluate {
uploadArchives.repositories {
mavenDeployer.pom.project {
description = project.description
}
}
}

uploadArchives.onlyIf {
!(isCI && isReleaseVersion)
}

uploadArchives.doFirst {
if (!isCI && isReleaseVersion && !JavaVersion.current().isJava8Compatible()) {
throw new GradleException("Releases have to be done with Java 8");
}
}

javadoc.onlyIf {
JavaVersion.current().isJava8Compatible()
}

idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
}

task overallJacocoReport(type: JacocoReport) {
Expand Down
1 change: 1 addition & 0 deletions jgiven-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
// in the individual module build.gradle files
}
}

apply plugin: 'com.android.library'

android {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include ':jgiven-spring'
include ':jgiven-html5-report'

def release = System.env.RELEASE == "true"
def android = System.env.ANDROUD == "true"
def android = System.env.ANDROID == "true"

// At least Java 7 is required for the tests as Selenium requires it
// Still the other projects should be built and tested with Java 6
Expand Down

0 comments on commit 41145fc

Please sign in to comment.