Skip to content

Commit

Permalink
Modified build script
Browse files Browse the repository at this point in the history
  • Loading branch information
psimonazzi committed Dec 18, 2015
1 parent 2548739 commit ed33dfd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 78 deletions.
14 changes: 4 additions & 10 deletions url-droid-jackson/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ targetCompatibility = "1.6"
version = '2.0.2'

repositories {
mavenCentral()
jcenter()
}

dependencies {
compile project(':url-droid')
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
testCompile 'junit:junit:4.11'
compile project(':url-droid')
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
testCompile 'junit:junit:4.11'
}


task wrapper(type: Wrapper,
description: 'Creates and deploys the Gradle wrapper to the current directory.') {
gradleVersion = '2.2'
}
6 changes: 3 additions & 3 deletions url-droid-jackson/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rootProject.name = 'url-droid-jackson'

def subprojects = [
[name:':url-droid', path:'../url-droid']
[name:':url-droid', path:'../url-droid']
]
subprojects.each { p ->
include new File(p.path).name
project(p.name).projectDir = new File(p.path)
include p.name
project(p.name).projectDir = new File(p.path)
}
8 changes: 4 additions & 4 deletions url-droid-jsonorg/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ targetCompatibility = "1.6"
version = '2.0.2'

repositories {
mavenCentral()
jcenter()
}

dependencies {
compile project(':url-droid')
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
testCompile 'junit:junit:4.11'
compile project(':url-droid')
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
testCompile 'junit:junit:4.11'
}
6 changes: 3 additions & 3 deletions url-droid-jsonorg/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
rootProject.name = 'url-droid-jsonorg'

def subprojects = [
[name:':url-droid', path:'../url-droid']
[name:':url-droid', path:'../url-droid']
]
subprojects.each { p ->
include new File(p.path).name
project(p.name).projectDir = new File(p.path)
include p.name
project(p.name).projectDir = new File(p.path)
}
106 changes: 50 additions & 56 deletions url-droid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,73 @@ sourceCompatibility = "1.6"
targetCompatibility = "1.6"
[compileJava, compileTestJava]*.options*.encoding = "UTF-8"

version = '2.0.4'
version = '2.1.0'

ext.buildTimestamp = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date())


repositories {
mavenCentral()
jcenter()
}


dependencies {
testCompile 'junit:junit:4.11'
testCompile 'junit:junit:4.11'
}


task sourcesAndClassesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from(sourceSets.main.allSource) {
exclude '**/app.properties'
}

from sourceSets.main.output.classesDir
// if we don't have app.properties to rewrite we could use this
//from sourceSets.main.allSource
tasks.withType(Jar) {
manifest = project.manifest {
attributes(
"Application-Version": version,
"Implementation-Version": version,
"Build-Timestamp": project.ext.buildTimestamp,
"Min-Java-Version": sourceCompatibility
)
}
}

// also copy source files in jar
// jar {
// from sourceSets.main.allSource
// }

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

artifacts {
archives sourcesAndClassesJar
//archives javadocJar
// Replace tokens with values in a properties file to be used by the app
afterEvaluate {
configure([processResources, sourcesJar]) {
from(sourceSets.main.resources.srcDirs) {
include '**/app.properties'
filter(org.apache.tools.ant.filters.ReplaceTokens,
tokens: [
version: project.version,
buildTimestamp: project.ext.buildTimestamp
])
}
}
}

Date buildTimeAndDate = new Date()
ext {
buildTimestamp = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(buildTimeAndDate)
}

// Replace tokens with values in a properties file to be used by the app
// processResources {
// from(sourceSets.main.resources.srcDirs) {
// include '**/app.properties'
// filter(org.apache.tools.ant.filters.ReplaceTokens,
// tokens: [
// version: project.version,
// gradleVersion: project.gradle.gradleVersion,
// buildTimestamp: project.ext.buildTimestamp
// ])
// }
// }
// or use this if we also want a jar with sources
afterEvaluate {
//TODO get list of tasks automatically
// if (tasks['sourcesAndClassesJar'])...
configure([processResources, sourcesAndClassesJar]) {
task sourcesJar(type: Jar, dependsOn: classes,
description: 'Create a jar that also includes sources') {
classifier = 'sources'
from sourceSets.main.output.classesDir
from(sourceSets.main.allSource) {
include '**/app.properties'
filter(org.apache.tools.ant.filters.ReplaceTokens,
tokens: [
version: project.version,
gradleVersion: project.gradle.gradleVersion,
buildTimestamp: project.ext.buildTimestamp
])
exclude '**/app.properties'
}
}
}


task wrapper(type: Wrapper,
description: 'Creates and deploys the Gradle wrapper to the current directory.') {
gradleVersion = '2.2'
task javadocJar(type: Jar, dependsOn: javadoc,
description: 'Create javadoc jar') {
classifier = 'javadoc'
from javadoc.destinationDir
}


// build additional artifacts
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}

3 changes: 1 addition & 2 deletions url-droid/src/main/resources/app.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
application.version = @version@
application.gradleVersion = @gradleVersion@
application.buildTimestamp = @buildTimestamp@
application.build = @buildTimestamp@

0 comments on commit ed33dfd

Please sign in to comment.