Skip to content

Commit

Permalink
Improve Gradle Build - refactoring and optimizations ( #388 )
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCoder4eu committed Jul 2, 2016
1 parent f3cbce9 commit e360a06
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 137 deletions.
152 changes: 43 additions & 109 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,126 +13,60 @@
* If not, see http://www.gnu.org/licenses/gpl-3.0.html
*/

//This is the main Project file where all Configurations are handled
Properties props = new Properties()
props.load(new FileInputStream("${projectDir}/build.properties"))
ext.BootsFacesVersion = props['VERSION']
//Bootstrap
ext.BootstrapVersion = props['bootstrap.version']
ext.themes= props['bootswatch.theme'].replaceAll("\\s","").tokenize(',')


// Apply the java plugin to add support for Java
apply plugin: 'java'
ext.themes= props['bootswatch.theme'].replaceAll("\\s","").tokenize(',')
ext.BootswatchFullVersion = props['bootstrap.version']+props['bootswatch.subversion']
//ext.BootswatchFolder = "${projectDir}"+'/Bootswatch/bootswatch-'+BootswatchFullVersion.replace('+','-')

//Configurations
sourceCompatibility = '1.6'
targetCompatibility = '1.6'
if(System.getProperty("BSF-THEME", "") != "") {
ext.themes= System.getProperty("BSF-THEME", "").replaceAll("\\s","").tokenize(',')
ext.allThemes= System.getProperty("BSF-THEME", "").replaceAll("\\s","").tokenize(',')
} else {
ext.themes= props['bootswatch.theme'].replaceAll("\\s","").tokenize(',')
ext.allThemes= ('default,'+props['bootswatch.theme']).replaceAll("\\s","").tokenize(',')
println 'Themes('+themes.size+'):'+props['bootswatch.theme']
}

archivesBaseName = 'BootsFaces-OSP-'+BootsFacesVersion
//jQuery options
ext.jqversion = props['jquery.version']
//Java options
ext.buildJava6 = ( ( props['java6']!=null) && props['java6'].toUpperCase().contains("YES") )
ext.buildJava7 = ( ( props['java7']!=null) && props['java7'].toUpperCase().contains("YES") )
ext.buildJava8 = ( ( props['java8']!=null) && props['java8'].toUpperCase().contains("YES") )

apply plugin: 'maven'
// Javac Compilation properties
ext.buildOptsJava6=["-g"]
ext.buildOptsJava7=["-g"]
ext.buildOptsJava8=["-g"]
if( props['java6opts']!=null) { ext.buildOptsJava6 = props['java6opts'].replaceAll("\\s","").tokenize(',') }
if( props['java7opts']!=null) { ext.buildOptsJava7 = props['java7opts'].replaceAll("\\s","").tokenize(',') }
if( props['java8opts']!=null) { ext.buildOptsJava8 = props['java8opts'].replaceAll("\\s","").tokenize(',') }

// Set the Artifact group ID
group = 'net.bootsfaces'
version = BootsFacesVersion

install {
repositories.mavenInstaller {
// only necessary if artifact ID diverges from project name
// the latter defaults to project directory name and can be
// configured in settings.gradle
pom.artifactId = 'bootsfaces'
// shouldn't be needed as this is the default anyway
pom.packaging = 'jar'
pom.version = "$BootsFacesVersion-SNAPSHOT"
}
}

repositories {
mavenCentral()
}

dependencies {
compile 'javax.servlet:servlet-api:3.+'
compile 'com.sun.faces:jsf-api:2.2.+'
compile 'javax.el:javax.el-api:3.0.0'
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:2.0.17-beta'
// testCompile 'org.jboss.arquillian.protocol:arquillian-protocol-servlet:1.1.8.Final'
// testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:2.1.1'
// testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven-archive:2.1.1'
// testCompile 'org.jboss.shrinkwrap.descriptors:shrinkwrap-descriptors-impl-javaee:2.0.0-alpha-7'
// testCompile 'org.jboss.arquillian.extension:arquillian-drone-webdriver-depchain:2.0.0.Alpha4'
// testCompile 'org.jboss.arquillian.graphene:graphene-webdriver-impl:2.1.0.Alpha2'
// testCompile 'org.jboss.arquillian.extension:arquillian-warp:1.0.0.Alpha4'
// testCompile 'org.jboss.arquillian.extension:arquillian-warp-jsf:1.0.0.Alpha4'
// testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.1.8.Final'
}

sourceSets {
main {
resources {
srcDirs = ["gradleResources/build/resources","src/main/meta"]
}
}
}

jar {
manifest {
attributes(
"Built-By": "BootsFaces OSP Gradle builder.",
"Gradle-Version": project.gradle.gradleVersion,
"Created-By": org.gradle.internal.jvm.Jvm.current(),
"Bundle-Name": "BootsFaces",
"Bundle-Version": BootsFacesVersion,
"Bundle-Date": (new Date()).format('yyyyMMdd-HH:mm:ss'),
"Implementation-Title": "BootsFaces",
"Implementation-Version": BootsFacesVersion,
"Implementation-Vendor": "TheCoder4.eu",
"Implementation-Vendor-Id": "eu.thecoder4",
"Implementation-URL":"http://www.bootsfaces.net"
)
}
}

task defaultJar(type: Jar) {
baseName='BootsFaces-OSP-'+BootsFacesVersion+'-default'
from(sourceSets.main.output.classesDir) {
include "**"
}
from(sourceSets.main.output.resourcesDir) {
include "META-INF/LICENSE"
include "META-INF/*.xml"
include "META-INF/resources/fonts/"
include "META-INF/resources/bsf/images/"
include "META-INF/resources/bsf/jq/"
include "META-INF/resources/bsf/js/"
include "META-INF/resources/bsf/css/default/"
include "META-INF/resources/bsf/css/icons.css"
}

manifest {
attributes(
"Built-By": "BootsFaces OSP Gradle builder.",
"Gradle-Version": project.gradle.gradleVersion,
"Created-By": org.gradle.internal.jvm.Jvm.current(),
"Bundle-Name": "BootsFaces",
"Bundle-Version": BootsFacesVersion,
"Bundle-Date": (new Date()).format('yyyyMMdd-HH:mm:ss'),
"Implementation-Title": "BootsFaces",
"Implementation-Version": BootsFacesVersion,
"Implementation-Vendor": "TheCoder4.eu",
"Implementation-Vendor-Id": "eu.thecoder4",
"Implementation-URL":"http://www.bootsfaces.net"
)
}
}
defaultJar.dependsOn(jar)
defaultJar.onlyIf { themes.size() > 0}
task buildJars (dependsOn: ['jar', 'defaultJar'])

task copyToLib(type: Copy) {
into "$buildDir/proguard/libs"
from configurations.runtime
task showConfig << {
println "Main Configurations."
println "--------------------"
println "BootsFacesVersion="+BootsFacesVersion
println "BootstrapVersion="+BootstrapVersion
println "BootswatchFullVersion="+BootswatchFullVersion
println "allThemes="+allThemes
println "jqversion="+jqversion
println "buildJava6:"+buildJava6
println "buildJava7:"+buildJava7
println "buildJava8:"+buildJava8
println "buildOptsJava6="+buildOptsJava6
println "buildOptsJava7="+buildOptsJava7
println "buildOptsJava8="+buildOptsJava8
println "--------------------"
}
compileJava.dependsOn(copyToLib)

defaultTasks 'gradleResources:buildResources', 'jar'
defaultTasks 'showConfig', ':java6:defaultJar', ':java7:jar', ':java8:jar'
31 changes: 29 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ VERSION=0.9.0
bootstrap.version=3.3.6

# Set global properties for this build
#bootstrap.dir=Bootstrap
#bsf.dir=BootsFaces
bsf.dir=gradleResources
bootstrap.dir=${bsf.dir}/Bootstrap

Expand All @@ -46,3 +44,32 @@ jquery.version=1.x
bootswatch.theme=cerulean,cosmo,cyborg,darkly,flatly,journal,lumen,paper,readable,sandstone,simplex,slate,spacelab,superhero,united,yeti

bootswatch.subversion=+1

# Optional Java target Compatibility properties
# You can build for multiple targets setting to 'Yes'(without quotes) the corresponding option
java6=Yes
#java7=yes
#java8=YES
# ADVANCED: Optional javac target compilation properties
# You can specify comma separated options for every target java version
# Examples
# -Xlint
# -Xlint:option (eg. -Xlint:unchecked)
# (default -g , all debugging information included)
# debugging options are:
# -g
# Generate all debugging information, including local variables. By default, only line number and source file information is generated.
# -g:none
# Do not generate any debugging information.
# -g:{keyword list}
# Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are:
# source
# Source file debugging information
# lines
# Line number debugging information
# vars
# Local variable debugging information
#java6opts=-Xlint:unchecked
#java7opts=-g,-Xlint:unchecked
#java8opts=-g:none

23 changes: 4 additions & 19 deletions gradleResources/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,8 @@
* If not, see http://www.gnu.org/licenses/gpl-3.0.html
*/

Properties props = new Properties()
props.load(new FileInputStream("${projectDir}/../build.properties"))
ext.BootstrapVersion = props['bootstrap.version']

ext.BootswatchFullVersion = props['bootstrap.version']+props['bootswatch.subversion']
ext.BootswatchFolder = "${projectDir}"+'/Bootswatch/bootswatch-'+BootswatchFullVersion.replace('+','-')
ext.jqversion = props['jquery.version']

if(System.getProperty("BSF-THEME", "") != "") {
ext.themes= System.getProperty("BSF-THEME", "").replaceAll("\\s","").tokenize(',')
ext.allThemes= System.getProperty("BSF-THEME", "").replaceAll("\\s","").tokenize(',')
} else {
ext.themes= props['bootswatch.theme'].replaceAll("\\s","").tokenize(',')
ext.allThemes= ('default,'+props['bootswatch.theme']).replaceAll("\\s","").tokenize(',')
println 'Themes('+themes.size+'):'+props['bootswatch.theme']
}
ext.themeFolder= 'default' //ext.theme?.length()>0?ext.theme:"default"

task getBootstrap(type: GradleBuild) {
description 'BootsFaces task: downloads and unzips Bootstrap.'
Expand Down Expand Up @@ -127,6 +112,7 @@ task copyBootsFacesFiles(type: Copy) {
//Compiles the assets
task lesscss(type: GradleBuild) {
description 'BootsFaces task: compiles the bs*.less files to *.css files.'

buildFile = 'lessc.gradle'
tasks = ['assetCompile']
}
Expand Down Expand Up @@ -172,7 +158,7 @@ task copyJsResources(type: Copy) {
from 'js/bootstrap-multiselect-collapsible-groups.js'
from 'js/bootstrap-multiselect.js'
from 'js/bootstrap-switch.js'
from 'js/bootstrap-tagsinput.min.js'
from 'js/bootstrap-tagsinput.min.js'
from 'js/bootstrap-tree.js'
from 'js/bootstrap-treeview.min.js'
from 'js/bootstrap-notify.min.js'
Expand Down Expand Up @@ -298,9 +284,7 @@ task copyAssetResources(dependsOn: ['copyAssetCss2Resources','copyIconsCss2Resou
task cleanMavenResources(type: Delete) {
description 'BootsFaces task: deletes every file in the mavenResource folder.'
delete fileTree(dir: "${projectDir}/../mavenResources/fonts")
//delete fileTree(dir: "${projectDir}/../mavenResources/bsf/css/${themeFolder}")
delete fileTree(dir: "${projectDir}/../mavenResources/bsf/css")
//delete fileTree(dir: "${projectDir}/../mavenResources/bsf/css/default")
delete fileTree(dir: "${projectDir}/../mavenResources/bsf/css")
delete fileTree(dir: "${projectDir}/../mavenResources/bsf/jq")
delete fileTree(dir: "${projectDir}/../mavenResources/bsf/js")
}
Expand Down Expand Up @@ -349,6 +333,7 @@ task buildResources(dependsOn: ['cleanBuildFolder', 'copyBootsFacesResources', '
'cleanMavenResources', 'updateMavenResources',
'updateGradleResources']) { //updateGradleResources just copies "other" Theme
description 'BootsFaces task: downloads Bootstrap from the internet and generates both the mavenResource folder and the Gradle resource folder from scratch.'

}

//defaultTasks 'buildResources'
17 changes: 10 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2014-2015 Riccardo Massera (TheCoder4.Eu)
* Copyright 2014-2016 Riccardo Massera (TheCoder4.Eu)
*
* This file is part of BootsFaces.
* BootsFaces is free software: you can redistribute it and/or modify it under the terms of
* BootsFaces is free software: you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
*
* BootsFaces is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* BootsFaces is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with BootsFaces.
Expand All @@ -15,6 +15,9 @@

// To declare projects as part of a multi-project build use the 'include' method

include 'gradleResources'

rootProject.name = 'BootsFaces'

include 'gradleResources'
include 'java6'
include 'java7'
include 'java8'

0 comments on commit e360a06

Please sign in to comment.