Skip to content

Commit

Permalink
Refactor module setup
Browse files Browse the repository at this point in the history
  • Loading branch information
blootsvoets committed Jun 26, 2018
1 parent 78286f8 commit a264e47
Show file tree
Hide file tree
Showing 66 changed files with 376 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ build/
/src/avroSources/java/

# Generated compile files
/out/
out/
backend.log
local.properties
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ deploy:
api_key: ${GH_TOKEN}
file_glob: true
file:
- "build/libs/*.jar"
- "testing/build/libs/*.jar"
- "*/build/libs/*.jar"
skip_cleanup: true
on:
tags: true
Expand Down
197 changes: 6 additions & 191 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
id 'com.jfrog.artifactory' version '4.5.4'
}

allprojects {
subprojects {
// Apply the plugins
apply plugin: 'java'
apply plugin: 'java-library'
Expand All @@ -41,16 +41,16 @@ allprojects {
ext.githubRepoName = 'RADAR-CNS/RADAR-Commons'

ext.slf4jVersion = '1.7.25'
ext.kafkaVersion = '0.11.0.1'
ext.kafkaVersion = '1.1.1-cp1'
ext.avroVersion = '1.8.2'
ext.confluentVersion = '3.3.1'
ext.jacksonVersion = '2.9.3'
ext.okhttpVersion = '3.9.1'
ext.confluentVersion = '4.1.1'
ext.jacksonVersion = '2.9.6'
ext.okhttpVersion = '3.10.0'
ext.junitVersion = '4.12'
ext.mockitoVersion = '2.13.0'
ext.hamcrestVersion = '1.3'
ext.codacyVersion = '2.0.1'
ext.radarSchemasVersion = '0.2.3'
ext.radarSchemasVersion = '0.3.4'
ext.orgJsonVersion = '20170516'

ext.githubUrl = 'https://github.com/' + githubRepoName + '.git'
Expand Down Expand Up @@ -178,191 +178,6 @@ allprojects {
}
}

targetCompatibility = '1.7'
sourceCompatibility = '1.7'

ext.description = 'RADAR Common utilities library containing streaming features and utils.'

//---------------------------------------------------------------------------//
// Sources and classpath configurations //
//---------------------------------------------------------------------------//

configurations {
codacy
}

configurations.compile {
resolutionStrategy.cacheChangingModulesFor 0, 'SECONDS'
}

// In this section you declare where to find the dependencies of your project
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

// In this section you declare the dependencies for your production and test code
dependencies {
api (group: 'org.apache.avro', name: 'avro', version: avroVersion) {
exclude group: 'org.xerial.snappy', module: 'snappy-java'
exclude group: 'com.thoughtworks.paranamer', module: 'paranamer'
exclude group: 'org.apache.commons', module: 'commons-compress'
exclude group: 'org.tukaani', module: 'xz'
}

// to implement producers and consumers
api group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion
api group: 'com.squareup.okhttp3', name: 'okhttp', version: okhttpVersion

// For POJO classes and ConfigLoader
implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jacksonVersion
implementation group: 'org.json', name: 'json', version: orgJsonVersion

// The production code uses the SLF4J logging API at compile time
implementation group: 'org.slf4j', name:'slf4j-api', version: slf4jVersion

// Direct producer uses KafkaAvroSerializer if initialized
testImplementation (group: 'io.confluent', name: 'kafka-avro-serializer', version: confluentVersion) {
exclude group: 'com.101tec'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
testImplementation group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
testImplementation group: 'junit', name: 'junit', version: junitVersion
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: hamcrestVersion
testImplementation group: 'com.squareup.okhttp3', name: 'mockwebserver', version: okhttpVersion
testRuntime group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion

codacy group: 'com.github.codacy', name: 'codacy-coverage-reporter', version: codacyVersion
}

//---------------------------------------------------------------------------//
// Testing //
//---------------------------------------------------------------------------//
checkstyle {
// ignore tests
sourceSets = [sourceSets.main]
}

pmd {
// ignore tests
sourceSets = [sourceSets.main]
}

jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
}
}

task downloadDependencies(type: Exec) {
configurations.testRuntime.files
configurations.codacy.files
configurations.jacocoAnt.files
commandLine 'echo', 'Downloaded all dependencies'
}

task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
main = 'com.codacy.CodacyCoverageReporter'
classpath = configurations.codacy
args = ['-l', 'Java', '-r', "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"]
}

//---------------------------------------------------------------------------//
// Build system metadata //
//---------------------------------------------------------------------------//

ext.sharedManifest = manifest {
attributes("Implementation-Title": rootProject.name,
"Implementation-Version": version)
}

jar {
manifest.from sharedManifest
}
// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
manifest.from sharedManifest
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
manifest.from sharedManifest
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives javadocJar
archives sourcesJar
}

publishing {
publications {
RadarCommonsPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId rootProject.name
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', rootProject.name)
root.appendNode('url', githubUrl)
root.children().last() + pomConfig
}
}
}
}

bintray {
user project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
override false
publications 'RadarCommonsPublication'
pkg {
repo = project.group
name = rootProject.name
userOrg = 'radar-cns'
desc = description
licenses = ['Apache-2.0']
websiteUrl = website
issueTrackerUrl = issueUrl
vcsUrl = githubUrl
githubRepo = githubRepoName
githubReleaseNotesFile = 'README.md'
version {
name = project.version
desc = description
vcsTag = System.getenv('TRAVIS_TAG')
released = new Date()
}
}
}

artifactory {
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
maven = true
}
}
}

artifactoryPublish {
publications('RadarCommonsPublication')
}

wrapper {
gradleVersion '4.8'
}
153 changes: 153 additions & 0 deletions radar-commons-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* Copyright 2017 The Hyve and King's College London
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

ext.moduleName = 'radar-commons-server'
ext.description = 'RADAR Common testing library mocking code and utilities.'

targetCompatibility = '1.8'
sourceCompatibility = '1.8'

repositories {
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

dependencies {
api project(':radar-commons')

// For POJO classes and ConfigLoader
implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jacksonVersion

api group: 'org.apache.avro', name: 'avro', version: avroVersion

implementation group: 'com.fasterxml.jackson.core' , name: 'jackson-databind' , version: jacksonVersion
implementation group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion

testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion
// Direct producer uses KafkaAvroSerializer if initialized
testImplementation (group: 'io.confluent', name: 'kafka-avro-serializer', version: confluentVersion) {
exclude group: 'com.101tec'
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
testImplementation group: 'org.radarcns', name: 'radar-schemas-commons', version: radarSchemasVersion
// Direct producer uses KafkaAvroSerializer if initialized
testImplementation group: 'junit', name: 'junit', version: junitVersion
testRuntime group: 'org.slf4j', name: 'slf4j-simple', version: slf4jVersion
}

checkstyle {
// ignore tests
sourceSets = [sourceSets.main]
ignoreFailures = false
}

pmd {
// ignore tests
sourceSets = [sourceSets.main]
ignoreFailures = false
}

ext.sharedManifest = manifest {
attributes("Implementation-Title": moduleName,
"Implementation-Version": version)
}

jar {
baseName moduleName
manifest.from sharedManifest
}

// custom tasks for creating source/javadoc jars
task sourcesJar(type: Jar, dependsOn: classes) {
baseName moduleName
classifier = 'sources'
from sourceSets.main.allSource
manifest.from sharedManifest
}

task javadocJar(type: Jar, dependsOn: javadoc) {
baseName moduleName
classifier = 'javadoc'
from javadoc.destinationDir
manifest.from sharedManifest
}

// add javadoc/source jar tasks as artifacts
artifacts {
archives sourcesJar, javadocJar
}

publishing {
publications {
RadarCommonsServerPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId project.group
artifactId moduleName
version project.version
pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', moduleName)
root.appendNode('url', githubUrl)
root.children().last() + pomConfig
}
}
}
}

bintray {
user project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
override false
publications 'RadarCommonsServerPublication'
pkg {
repo = project.group
name = moduleName
userOrg = 'radar-cns'
desc = description
licenses = ['Apache-2.0']
websiteUrl = website
issueTrackerUrl = issueUrl
vcsUrl = githubUrl
githubRepo = githubRepoName
githubReleaseNotesFile = 'README.md'
version {
name = project.version
desc = description
vcsTag = System.getenv('TRAVIS_TAG')
released = new Date()
}
}
}


artifactory {
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
maven = true
}
}
}

artifactoryPublish {
publications('RadarCommonsServerPublication')
}
Loading

0 comments on commit a264e47

Please sign in to comment.