Skip to content

Instantly share code, notes, and snippets.

@alexeyr
Last active May 7, 2017 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alexeyr/7544845 to your computer and use it in GitHub Desktop.
Save alexeyr/7544845 to your computer and use it in GitHub Desktop.
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'Apache S4'
defaultTasks 'assemble'
project.ext["archivesBaseName"] = 'apache-s4'
project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
allprojects {
// Append the suffix 'SNAPSHOT' when the build is not for release.
version = new Version(major: 0, minor: 6, bugfix: 0, isRelease: true)
group = 'org.apache.s4'
/* Search these repos to find artifacts. Gradle will download and cache. */
repositories {
mavenCentral()
mavenLocal()
maven { url 'http://google-gson.googlecode.com/svn/mavenrepo' }
maven { url 'https://repo.springsource.org/libs-release' }
maven { url 'http://repo.gradle.org/gradle/libs-releases-local' }
/* Add lib dir as a repo. Some jar files that are not available
in a public repo are distributed in the lib dir. */
flatDir name: 'libDir', dirs: "$rootDir/lib"
}
configurations.all {
transitive = false
}
}
/* All project libraries must be defined here. */
project.ext["libraries"] = [
guava: 'com.google.guava:guava:13.0.1',
gson: 'com.google.code.gson:gson:1.6',
guice: 'com.google.inject:guice:3.0',
aop_alliance: 'aopalliance:aopalliance:1.0',
guice_assist: 'com.google.inject.extensions:guice-assistedinject:3.0',
kryo: 'com.esotericsoftware.kryo:kryo:2.20',
minlog: 'com.googlecode:minlog:1.2',
// NOTE shaded jar is not resolved correctly, we include it in /lib directory
reflectasm: 'com.esotericsoftware.reflectasm:reflectasm:1.07:shaded',
netty: 'io.netty:netty:3.5.11.Final',
mockito_core: 'org.mockito:mockito-core:1.9.0',
commons_config: 'commons-configuration:commons-configuration:1.6',
commons_codec: 'commons-codec:commons-codec:1.4',
commons_coll: 'net.sourceforge.collections:collections-generic:4.01', // Use this lib until the commons collection with Generics is released.
commons_io: 'commons-io:commons-io:2.4',
commons_lang: 'commons-lang:commons-lang:2.6',
commons_logging: 'commons-logging:commons-logging:1.1.1',
commons_collections:'commons-collections:commons-collections:3.2.1',
objenesis: 'org.objenesis:objenesis:1.2',
slf4j: 'org.slf4j:slf4j-api:1.6.1',
log4j: 'log4j:log4j:1.2.15',
logback_core: 'ch.qos.logback:logback-core:0.9.29',
logback_classic: 'ch.qos.logback:logback-classic:0.9.29',
zk: 'org.apache.zookeeper:zookeeper:3.3.3',
jcip: 'net.jcip:jcip-annotations:1.0',
junit: 'junit:junit:4.10',
zkclient: 'com.github.sgroschupf:zkclient:0.1',
diezel: 'net.ericaro:diezel-maven-plugin:1.0.0-beta-4',
jcommander: 'com.beust:jcommander:1.25',
asm: 'org.ow2.asm:asm:4.0',
javax_inject: 'javax.inject:javax.inject:1',
gradle_base_services: 'org.gradle:gradle-base-services:1.4',
gradle_core: 'org.gradle:gradle-core:1.4',
gradle_tooling_api: 'org.gradle:gradle-tooling-api:1.4',
gradle_wrapper: 'org.gradle:gradle-wrapper:1.4',
metrics: 'com.yammer.metrics:metrics-core:2.1.3'
]
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'maven-publish'
// apply plugin: 'checkstyle'
/* Set Java version. */
sourceCompatibility = 1.6
targetCompatibility = 1.6
project.ext["checkstyleConfigFileName"] = "$rootDir/config/checkstyle/s4-checkstyle.xml"
configurations.all {
exclude group: 'com.sun.jdmk', module: 'jmxtools'
exclude group: 'com.sun.jmx', module: 'jmxri'
exclude group: 'javax.jms', module: 'jms'
exclude group: 'javax.mail', module: 'mail'
}
dependencies {
/* Google. */
compile ( libraries.guava )
compile ( libraries.guice )
compile ( libraries.guice_assist)
/* Logging. */
compile( libraries.slf4j )
compile( libraries.logback_core )
compile( libraries.logback_classic )
runtime( libraries.commons_logging)
/* Commons. */
compile( libraries.commons_config )
compile( libraries.commons_coll )
compile( libraries.commons_io )
compile ( libraries.commons_lang )
runtime(libraries.commons_collections)
/* Misc. */
compile( libraries.jcip )
compile( libraries.zk )
compile( libraries.metrics )
/* Testing. */
testCompile( libraries.junit )
// transitive
runtime( libraries.log4j) // required by Zookeeper
runtime(libraries.aop_alliance)
runtime(libraries.minlog)
runtime(libraries.gson)
compile(libraries.reflectasm)
runtime(libraries.objenesis)
runtime(libraries.kryo)
runtime(libraries.netty)
runtime(libraries.asm)
compile(libraries.javax_inject)
runtime(libraries.commons_codec)
}
jar {
from (rootDir) {
include "NOTICE"
include "LICENSE"
into "META-INF"
}
}
manifest.mainAttributes(
provider: 'gradle',
'Implementation-Url': 'http://incubator.apache.org/s4/',
'Implementation-Version': version,
'Implementation-Vendor': 'Apache Software Foundation',
'Implementation-Vendor-Id': 'org.apache',
'Implementation-Title': 'org.apache.s4.'+project.name.substring(3) // s4-comm becomes org.apache.s4.comm for instance
)
configurations {
deployerJars
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-http:2.2"
}
uploadArchives {
configuration = configurations.deployerJars
repositories {
mavenDeployer {
repository(url: "http://127.0.0.1:9081/nexus/content/repositories/releases/") {
authentication(userName: "admin", password: "admin123")
}
}
}
// repositories {
// maven {
// credentials {
// username "admin"
// password "admin123"
// }
// url "http://127.0.0.1:9081/nexus/content/repositories/releases/"
// }
// }
}
}
evaluationDependsOnChildren()
project.ext["platformProjects"] = [project(':s4-base'), project(':s4-core'), project(':s4-comm'), project(':s4-tools'), project(':s4-benchmarks')]
configurations {
platformLibs
}
dependencies {
platformLibs platformProjects
}
task javadoc (type: Javadoc) {
destinationDir = new File(project.rootDir, 'doc/javadoc')
destinationDir.deleteDir()
excludes = ['org.apache.s4.benchmark']
project.ext["documentedProjects"] = new HashSet(platformProjects)
documentedProjects.remove(project(':s4-benchmarks'))
title = "Apache S4 " + version
source documentedProjects.collect { project ->
project.sourceSets.main.allJava
}
// Might need a classpath
classpath = files(documentedProjects.collect { project ->
project.sourceSets.main.compileClasspath
})
}
// TODO parameterize
task javadocBinRelease (type: Javadoc) {
destinationDir = new File(project.rootDir,'subprojects/s4-tools/src/dist/doc/javadoc')
destinationDir.deleteDir()
title = "Apache S4 " + version
source platformProjects.collect { project ->
project.sourceSets.main.allJava
}
// Might need a classpath
classpath = files(subprojects.collect { project ->
project.sourceSets.main.compileClasspath
})
}
task copyRequiredFilesForBinaryRelease (type: Copy) {
copy {
from (rootDir) {
include "README.md"
include "DISCLAIMER"
include "gradlew"
include "s4"
}
into new File(project.rootDir.path+'/subprojects/s4-tools/src/dist/')
}
copy {
// binary release specifics
from (rootDir.path + "/config/binrelease/")
into new File(project.rootDir.path+'/subprojects/s4-tools/src/dist/')
include "*"
}
File s4DistFile = new File(project.rootDir.path+'/subprojects/s4-tools/src/dist/s4')
ant.replace(file: s4DistFile, token: "\n# NOTE: \"./gradlew s4-tools:installApp\" will prepare/update the tools subproject and related startup scripts", value: "")
ant.replace(file: s4DistFile, token: "subprojects/s4-tools/build/install/s4-tools/", value: "")
ant.chmod(file: s4DistFile, perm: "700")
copy {
from new File(rootDir, 'gradle')
into new File(project.rootDir.path+'/subprojects/s4-tools/src/dist/gradle')
}
copy {
from (new File(rootDir, 'lib')) {
include '*.properties'
}
into new File(project.rootDir.path+'/subprojects/s4-tools/src/dist/lib')
}
}
task binDist(dependsOn: ["s4-tools:clean", "javadocBinRelease", "copyRequiredFilesForBinaryRelease", "s4-tools:cleanDistZip", "s4-tools:distZip"]) {
doFirst {
new File(project.rootDir.path+'/subprojects/s4-tools/src/dist').deleteDir()
}
doLast {
copy {
from (project.rootDir.path+"/subprojects/s4-tools/build/distributions/")
into (project.buildDir)
exclude('tmp')
}
}
}
task srcDist(type: Zip) {
doFirst {
platformProjects.collect { project ->
project.tasks.clean.execute()
}
new File(project.rootDir.path+'/subprojects/s4-tools/src/dist').deleteDir()
}
classifier='src'
version = project.version
baseName=project.ext.archivesBaseName
destinationDir = project.buildDir
from (project.rootDir)
exclude ('**/.project')
exclude ('**/.classpath')
exclude ('.rat-excludes')
exclude ('**/.gradle/**')
exclude ('**/.settings/**')
exclude ('**/build/**')
exclude ('**/tmp/**')
exclude ('**/bin/**')
exclude ('website/**')
exclude ('lib')
exclude ('gradlew')
exclude ('RELEASE_NOTES.html')
exclude ('config')
exclude ('subprojects/s4-benchmarks/config/injector.config')
exclude ('subprojects/s4-benchmarks/config/node.config')
into (baseName+'-'+version+'-'+classifier)
}
task rat(type: JavaExec) {
print("Runs Apache RAT. Exclusions are defined in .rat-excludes file")
main = 'org.apache.rat.Report'
classpath = files ('lib/apache-rat-0.8.jar')
args = ['-E', '.rat-excludes', '--dir', '.']
}
task clean << {
delete buildDir
}
/* Generates the gradlew scripts.
http://www.gradle.org/docs/1.0/userguide/gradle_wrapper.html */
task wrapper(type: Wrapper) {
gradleVersion = '1.4'
jarFile='lib/gradle-wrapper-1.4.jar'
}
class Version {
int major
int minor
int bugfix
boolean isRelease
String toString() {
"$major.$minor.$bugfix${isRelease ? '' : '-SNAPSHOT'}-incubating"
}
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'Interfaces and most basic classes required by nultiple modules.'
dependencies {
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
project.ext["s4Version"] = '0.6.0-incubating'
description = 'Apache S4 App'
project.ext["archivesBaseName"] = "$project.name"
project.ext["distRootFolder"] = "$archivesBaseName-${-> version}"
// Append the suffix 'SNAPSHOT' when the build is not for release.
//version = new Version(major: 0, minor: 0, bugfix: 0, isRelease: false)
group = 'org.apache.s4'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
/* Set Java version. */
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
mavenLocal()
mavenRepo name: "gson", url: "http://google-gson.googlecode.com/svn/mavenrepo"
/* Add lib dir as a repo. Some jar files that are not available
in a public repo are distributed in the lib dir. */
}
dependencies {
/* S4 Platform. We only need the API, not the transitive dependencies. */
compile project( ":s4-base" )
compile project( ":s4-core" )
compile project( ":s4-comm" )
compile (libraries.jcommander)
compile (libraries.zkclient)
compile (libraries.metrics)
// if you need to use the twitter4j lib defined above, you must reference it here as a dependency
// compile (libraries.twitter4j_core)
}
task cp << {
description='Dumps the classpath for running a class from this project, into a \'classpath.txt\' file in the current directory'
String rt = ""
configurations.runtime.files.each{File file -> rt+=(file.path+File.pathSeparator) }
new File("classpath.txt").write(sourceSets.main.output.classesDir.path + File.pathSeparator + rt)
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'Implementation-specific components of the communication layer.'
dependencies {
compile project(":s4-base")
compile libraries.gson
compile libraries.kryo
compile libraries.netty
compile (libraries.zkclient)
}
task testJar(type: Jar) {
baseName = "test-${project.archivesBaseName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
test {
forkEvery=1
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'The S4 core platform.'
dependencies {
compile project(":s4-base")
compile project(":s4-comm")
compile libraries.commons_codec
compile libraries.jcommander
compile libraries.asm
compile libraries.netty
compile libraries.zkclient
compile libraries.reflectasm
testCompile project(path: ':s4-comm', configuration: 'tests')
testCompile libraries.gradle_base_services
testCompile libraries.gradle_core
testCompile libraries.gradle_tooling_api
testCompile libraries.gradle_wrapper
testCompile libraries.mockito_core
}
task testJar(type: Jar) {
baseName = "test-${project.archivesBaseName}"
from sourceSets.test.output
}
configurations {
tests
}
artifacts {
tests testJar
}
test {
forkEvery=1;
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
def generatedSourceDir = "${buildDir}/generated-src/java"
def diezelSrcDir = "${projectDir}/src/main/diezel";
dependencies {
compile project(":s4-base")
compile project(":s4-comm")
compile project(":s4-core")
testCompile project(path: ':s4-comm', configuration: 'tests')
testRuntime libraries.zkclient
testRuntime libraries.netty
testRuntime libraries.asm
}
sourceSets {
generated {
java { srcDir generatedSourceDir }
}
}
buildscript {
repositories {
mavenCentral()
maven {
url "http://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url "http://oss.sonatype.org/content/repositories/releases"
}
}
dependencies {
classpath libraries.diezel
}
}
task generateSources << {
outputs.dir generatedSourceDir
def mojo = new net.ericaro.diezel.plugin.DiezelMojo()
mojo.sourceDirectory = new File(diezelSrcDir);
mojo.outputDirectory = new File(generatedSourceDir);
mojo.staleMillis = 0;
mojo.project = new org.apache.maven.project.MavenProject();
org.apache.maven.model.Build build = new org.apache.maven.model.Build();
build.setDirectory(mojo.sourceDirectory.getAbsolutePath());
mojo.project.setBuild(build);
mojo.execute();
}
compileJava.source generateSources.outputs.files, sourceSets.main.java
eclipseClasspath.dependsOn generateSources
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'Examples of S4 applications.'
dependencies {
compile project( ":s4-base" )
compile project( ":s4-core" )
compile project( ":s4-comm" )
compile project( ":s4-edsl" )
compile libraries.junit
compile libraries.jcip
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
description = 'The S4 tools platform.'
apply plugin: 'java'
task "create-dirs" << {
sourceSets.all*.java.srcDirs*.each { it.mkdirs() }
sourceSets.all*.resources.srcDirs*.each { it.mkdirs() }
}
dependencies {
compile project(":s4-base")
compile project(":s4-comm")
compile project(":s4-core")
compile libraries.jcommander
compile libraries.zkclient
compile libraries.gradle_base_services
compile libraries.gradle_core
compile libraries.gradle_tooling_api
compile libraries.gradle_wrapper
compile libraries.log4j
testCompile project(path: ':s4-comm', configuration: 'tests')
testCompile project(path: ':s4-core', configuration: 'tests')
}
apply plugin:'application'
mainClassName = "org.apache.s4.tools.Tools"
task copyTemplates << {
copy {
from 'src/main/java/hello'
into 'src/main/resources'
}
}
run {
// run doesn't yet directly accept command line parameters...
if ( project.hasProperty('args') ) {
args project.args.split('\\s+')
print args
}
}
distZip {
// what we build here is really a binary release of S4 with required subprojects and dependencies (hence refs to rootProject)
classifier='bin'
version = rootProject.version
baseName=rootProject.ext.archivesBaseName
}
test {
forkEvery=1
}
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
include 's4-base'
include 's4-core'
include 's4-comm'
//include 's4-edsl'
//include 's4-example'
include 's4-tools'
include 's4-benchmarks'
//include 's4-example'
//include ':test-apps:simple-adapter-1'
include ':test-apps:simple-deployable-app-1'
include ':test-apps:producer-app'
include ':test-apps:consumer-app'
rootProject.name = 's4'
rootProject.children.each {project ->
if (project.name != 'test-apps') {
String fileBaseName = project.name.replaceAll("\\p{Upper}") { "-${it.toLowerCase()}" }
String projectDirName = "subprojects/$fileBaseName"
project.projectDir = new File(settingsDir, projectDirName)
project.buildFileName = "${fileBaseName}.gradle"
assert project.projectDir.isDirectory()
assert project.buildFile.isFile()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment