Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
223 lines (194 sloc) 6.16 KB
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
}
}
plugins {
id 'io.codearte.nexus-staging' version '0.11.0'
id 'ru.vyarus.pom' version '1.2.0'
}
apply plugin: 'java'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply from: 'gitCommands.gradle'
version '1.2'
group 'de.schlegel11'
description = 'Decorator and strategy lambda mixture'
sourceCompatibility = 1.8
targetCompatibility = 1.8
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
options
{
setMemberLevel JavadocMemberLevel.PUBLIC
setAuthor true
links "https://docs.oracle.com/javase/8/docs/api/"
}
}
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}
artifacts {
archives sourceJar
archives javadocJar
}
task signPom(type: Sign) {
sign project.file('build/publications/mavenJava/pom-default.xml')
outputs.upToDateWhen { false } // the signing plugin does not seem to notice
// it when the publications folder with the
// signature has been deleted. So we always
// create a new signature
}
task releaseLambdaDecor(type: GradleBuild) {
tasks = ['publishMavenJavaPublicationToNexusReleaseRepository',
'closeAndReleaseRepository',
'commitDocs',
'createReleaseTag']
}
task commitDocs {
def javadocDir = "${project.docsDir}/javadoc"
def gitDestDir = "${project.projectDir}/releases/${project.version}/api/docs"
def branch = 'gh-pages'
def commitMessage = "Gradle auto commit for docs ${project.version}"
doFirst {
project.tasks.create('annonymCopyTask', Copy) {
from javadocDir
into gitDestDir
}
}
doLast {
git.switchCreateEmptyBranch(branch) {
annonymCopyTask.execute()
if (annonymCopyTask.state.skipped && !annonymCopyTask.state.upToDate) {
throw new GradleException("Copy doc files -> FAIL: ${annonymCopyTask.state.skipMessage ?: ''}")
}
println "Copy doc files -> OK: ${annonymCopyTask.state.skipMessage ?: ''}"
if (!git.hasFilesUpToDate(gitDestDir)) {
println("Add/Update files to ${branch}")
println("Modified files are:\n ${git.getModifiedFiles(gitDestDir)}")
git.add(gitDestDir)
println('Commit changes')
git.commit(commitMessage)
println "Commit doc files to ${branch} -> OK"
} else {
println "Commit doc files to ${branch} -> OK: UP-TO-DATE"
}
}
}
}
task createReleaseTag {
def branch = 'master'
def tag = "v${version}"
onlyIf { !git.hasTag(tag) }
doLast {
git.switchCreateBranch(branch) {
git.createTag(tag, 'auto created tag')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
project.tasks.withType(Sign) {
signatures.all {
def type = it.type
if (it.file.name.endsWith('.tar.gz.asc')) {
// Workaround in case a tar.gz file should published
type = 'tar.gz.asc'
} else if (it.type == 'xml.asc') { // Set correct extension for signature of pom file
type = 'pom.asc'
}
artifact source: it.file, classifier: it.classifier ?: null, extension: type
}
}
jar {
into("META-INF/maven/$project.group/$project.name") {
from { generatePomFileForMavenJavaPublication }
rename ".*", "pom.xml"
}
}
}
}
pom {
packaging 'jar'
url 'http://lambdadecor.schlegel11.de'
scm {
connection 'scm:git://github.com/schlegel11/LambdaDecor.git'
developerConnection 'scm:git:git@github.com:schlegel11/LambdaDecor.git'
url 'https://github.com/schlegel11/LambdaDecor'
}
issueManagement {
system 'GitHub Issues'
url 'https://github.com/schlegel11/LambdaDecor/issues'
}
licenses {
license {
name 'The MIT License (MIT)'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
}
}
developers {
developer {
id 'schlegel11'
name 'Marcel Schlegel'
email 'develop@schlegel11.de'
url 'http://schlegel11.de'
}
}
}
repositories.maven {
name 'NexusRelease'
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
credentials {
username = System.getProperty('nexus.username')
password = System.getProperty('nexus.password')
}
}
}
model {
tasks.publishMavenJavaPublicationToNexusReleaseRepository {
dependsOn project.tasks.withType(Sign)
}
tasks.signPom {
dependsOn tasks.generatePomFileForMavenJavaPublication
}
}
signing {
required = true
sign configurations.archives
}
signArchives.onlyIf { System.getProperty('doSign') != null }
nexusStaging {
username = System.getProperty('nexus.username')
password = System.getProperty('nexus.password')
numberOfRetries = 10
delayBetweenRetriesInMillis = 10000
}
repositories {
mavenCentral()
}
dependencies {
testCompile 'org.assertj:assertj-core:3.8.0'
testCompile 'org.apiguardian:apiguardian-api:1.0.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.0.2'
}
You can’t perform that action at this time.