diff --git a/README.md b/README.md index a33454b..718034a 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ MIT License. Use it at will, just don't sue me. -# Dependencies +## Dependencies The only dependency is the SLF4 API (MIT License as well). diff --git a/build.gradle b/build.gradle index 1e93e09..b67bef5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,107 @@ + + +import java.text.SimpleDateFormat +def globalVersion = new Version(version) + task wrapper(type: Wrapper) { gradleVersion = '3.0' +} + +// configures all sub-projects consistently +subprojects { + apply plugin: 'java' + + version = globalVersion + status = version.status + + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + + repositories { + mavenCentral() + jcenter() + } + + buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1' + } + } + + task sourceJar(type: Jar) { + from sourceSets.main.allSource + classifier = 'sources' + } + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + + // publishing artifacts to Bintray JCenter + configurations { + published + } + + // upload to JCenter + artifacts { + published sourceJar + published javadocJar + } + + apply plugin: 'com.jfrog.bintray' + apply plugin: 'maven' + + ext.publish = true + bintray { + // grab credentials from environment variables + user = "$System.env.BINTRAY_USER" + key = "$System.env.BINTRAY_API_KEY" + + configurations = ['published', 'archives'] + dryRun = false //Whether to run this as dry-run, without deploying + publish = true //If version should be auto published after an upload + pkg { + repo = 'structlog4j' + name = project.name + desc = 'Structured logging for Java on top of the SLF4jAPI' + websiteUrl = 'https://github.com/jacek99/structlog4j' + issueTrackerUrl = 'https://github.com/jacek99/structlog4j' + vcsUrl = 'https://github.com/jacek99/structlog4j' + licenses = ['MIT'] + publicDownloadNumbers = true + } + } +} + +class Version { + String originalVersion + String thisVersion + String status + Date buildTime + + Version(String versionValue) { + buildTime = new Date() + originalVersion = versionValue + if (originalVersion.endsWith('-SNAPSHOT')) { + status = 'integration' + thisVersion = originalVersion.substring(0, originalVersion.length() - 'SNAPSHOT'.length()) + getTimestamp() + } else { + status = 'release' + thisVersion = versionValue + } + } + + String getTimestamp() { + // Convert local file timestamp to UTC + def format = new SimpleDateFormat('yyyyMMddHHmmss') + format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC'))); + return format.format(buildTime) + } + + String toString() { + thisVersion + } } \ No newline at end of file diff --git a/structlog4j-api/build.gradle b/structlog4j-api/build.gradle index b06a834..5ff3ba7 100644 --- a/structlog4j-api/build.gradle +++ b/structlog4j-api/build.gradle @@ -1,9 +1,3 @@ -apply plugin: 'java' - -repositories { - mavenCentral() -} - dependencies { // Lombok is KING