Skip to content

Commit

Permalink
Gradle Build rewrite to improve efficiency, drop legacy Java and buil…
Browse files Browse the repository at this point in the history
…d only LTS runtimes.
  • Loading branch information
TheCoder4eu committed Dec 30, 2021
1 parent 40d872e commit 734833d
Show file tree
Hide file tree
Showing 4 changed files with 324 additions and 43 deletions.
32 changes: 7 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,18 @@ if(System.getProperty("BSF-THEME", "") != "") {
//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") )
//ext.buildJava9 = ( ( props['java9']!=null) && props['java9'].toUpperCase().contains("YES") )
ext.buildJava10 = ( ( props['java10']!=null) && props['java10'].toUpperCase().contains("YES") )
ext.buildJava11 = ( ( props['java11']!=null) && props['java11'].toUpperCase().contains("YES") )
ext.buildJava17 = ( ( props['java17']!=null) && props['java17'].toUpperCase().contains("YES") )

// Javac Compilation properties
//ext.buildOptsJava6=["-g"]
ext.buildOptsJava7=["-g"]
ext.buildOptsJava=["-g"]
ext.buildOptsJava8=["-g"]
ext.buildOptsJava9=["-g"]
ext.buildOptsJava10=["-g"]
ext.buildOptsJava11=["-g"]
//if( props['java6opts']!=null) { ext.buildOptsJava6 = props['java6opts'].replaceAll("\\s","").tokenize(',') }
if( props['java7opts']!=null) { ext.buildOptsJava7 = props['java7opts'].replaceAll("\\s","").tokenize(',') }
ext.buildOptsJava17=["-g"]
if( props['java8opts']!=null) { ext.buildOptsJava8 = props['java8opts'].replaceAll("\\s","").tokenize(',') }
//if( props['java9opts']!=null) { ext.buildOptsJava9 = props['java9opts'].replaceAll("\\s","").tokenize(',') }
if( props['java10opts']!=null) { ext.buildOptsJava10 = props['java10opts'].replaceAll("\\s","").tokenize(',') }
if( props['java11opts']!=null) { ext.buildOptsJava11 = props['java11opts'].replaceAll("\\s","").tokenize(',') }
if( props['java17opts']!=null) { ext.buildOptsJava17 = props['java17opts'].replaceAll("\\s","").tokenize(',') }
ext.useBootClasspath= ( ( props['enableBootClasspath']!=null) && props['enableBootClasspath'].toUpperCase().contains("YES") )
// Set the Artifact group ID
group = 'net.bootsfaces'
Expand All @@ -91,18 +83,9 @@ task showConfig {
println "allThemes="+allThemes
println "jqversion="+jqversion
println "--------Java--------"
//println "buildJava6:"+buildJava6
//println "buildJava7:"+buildJava7
println "buildJava8:"+buildJava8
//println "buildJava9:"+buildJava9
println "buildJava10:"+buildJava10
println "buildJava11:"+buildJava11
//println "buildOptsJava6="+buildOptsJava6
//println "buildOptsJava7="+buildOptsJava7
println "buildOptsJava8="+buildOptsJava8
//println "buildOptsJava9="+buildOptsJava9
println "buildOptsJava10="+buildOptsJava10
println "buildOptsJava11="+buildOptsJava11
println "buildJava17:"+buildJava17
println "buildOptsJava="+buildOptsJava
println "useBootClasspath="+useBootClasspath
println "--------------------"
}
Expand All @@ -122,5 +105,4 @@ showConfig.doFirst {
}

//By default build also the default( plain Bootstrap without Themes ) Jar for Java 8 and 9 only
//defaultTasks 'showConfig', ':java8:defaultJar', ':java9:defaultJar', ':java10:defaultJar', ':java7:jar', ':java6:jar'
defaultTasks 'showConfig', ':java8:defaultJar', ':java11:defaultJar' //, ':java17:defaultJar' //Next LTS?
defaultTasks 'showConfig', ':javaBuild:defaultJar',':javaBuild:buildJava11Jar', ':javaBuild:buildJava8Jar' //':java8:defaultJar', ':java11:defaultJar', ':java17:defaultJar' //Java 17 LTS
13 changes: 4 additions & 9 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,10 @@ patternfly.version=3.18.1
# Starting with BootsFaces v1.2.0+ Java 6 will be deprecated.
# Starting with BootsFaces v1.3.0 Java 10 will be preferred over Java 9 (No-LTS release).
# Starting with BootsFaces v1.3.1 Java 11 LTS release will be supported dropping Java 9 and Java 10 (No-LTS releases).
# First LTS Release after Java 8 is Java 11, released september 2018
# Default Build uses Java 8
###java6=NO #DROPPED
###java7=NO #DROPPED
java8=YES
java9=No
java10=No
# The LTS Releases after Java 8 are Java 11, released september 2018 and Java 17, released september 2021
# Default Build uses Java 8, you can build tdditional jars for the other LTS releases by setting to yes the corresponding variable.
java11=YES
java17=YES
# ADVANCED: Optional javac target compilation properties
# You can specify comma separated options for every target java version
# Examples
Expand All @@ -89,8 +85,7 @@ java11=YES
# Line number debugging information
# vars
# Local variable debugging information
###java6opts=-Xlint:all
#java7opts=-g,-Xlint:unchecked
#java8opts=-g,-Xlint:unchecked
#java8opts=-g:none
java8opts=-Xlint:all
# ADVANCED: Optional bootClasspath compilation (default is No)
Expand Down
303 changes: 303 additions & 0 deletions javaBuild/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
/*
* Copyright 2014-2022 Riccardo Massera (TheCoder4.Eu)
*
* This file is part of BootsFaces.
*
* 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.
*/


// Apply the java-library plugin to add support for Java
plugins {
id 'java-library'
id 'maven-publish'
}


// Set the Artifact group ID
group = 'net.bootsfaces'
version = "$pomVersion"

//Configurations for Target Java runtime.
def gradleJavaRuntimeVersion=org.gradle.internal.jvm.Jvm.current().getJavaVersion().getMajorVersion().toInteger()

def toolchainVersion=8;
if(buildJava11==true) toolchainVersion=11;
if(buildJava17==true) toolchainVersion=17;

ext.buildOptsJava=''//-Xlint:all'

sourceSets {
main {
java {
srcDir '../src/main/java'
}
resources {
srcDirs = ["../gradleResources/build/resources","../src/main/meta"]
}
}
java11 {
java {
srcDir '../src/main/java'
}
resources {
srcDirs = ["../gradleResources/build/resources","../src/main/meta"]
}
// Compiled Java classes should use this directory
java.destinationDirectory.set(file('build/java11/classes'))
}
java17 {
java {
srcDir '../src/main/java'
}
resources {
srcDirs = ["../gradleResources/build/resources","../src/main/meta"]
}
// Compiled Java classes should use this directory
java.destinationDirectory.set(file('build/java17/classes'))
}

}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(toolchainVersion)
//languageVersion = JavaLanguageVersion.of(8)
//if(gradleJavaRuntimeVersion>=17) languageVersion = JavaLanguageVersion.of(17)
//if((gradleJavaRuntimeVersion<17) && (gradleJavaRuntimeVersion>=11)) languageVersion = JavaLanguageVersion.of(11)
}
withJavadocJar()
withSourcesJar()

}

archivesBaseName = 'BootsFaces-OSP'

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
//options.fork = true
//options.compilerArgs.addAll(0,buildOptsJava)
}

compileJava11Java {
sourceCompatibility = '1.8'
targetCompatibility = '11'
source = sourceSets.java11.java.srcDirs
classpath = sourceSets.main.compileClasspath
//options.fork = true
//options.compilerArgs.addAll(0,buildOptsJava)
destinationDirectory.set(file('build/java11/classes'))
}
compileJava11Java.doFirst { println "Running compileJava11Java" }

compileJava17Java {
sourceCompatibility = '1.8'
targetCompatibility = '17'
source = sourceSets.java17.java.srcDirs
classpath = sourceSets.main.compileClasspath
//options.fork = true
//options.compilerArgs.addAll(0,buildOptsJava)
destinationDirectory.set(file('build/java17/classes'))
}
compileJava17Java.doFirst { println "Running compileJava17Java" }

repositories {
mavenCentral()
}

dependencies {
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
compileOnly 'com.sun.faces:jsf-api:2.2.14'
compileOnly 'javax.el:javax.el-api:3.0.0'
compileOnly 'com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20191001.1'
testImplementation 'junit:junit:4.11'
testImplementation 'org.mockito:mockito-core:2.0.17-beta'
//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'
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'bootsfaces'
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
}
}
repositories {
mavenLocal()
}
}

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":"https://www.bootsfaces.net"
)
}
}
jar.dependsOn(":gradleResources:buildResources")

task defaultJar(type: Jar) {
archiveBaseName='BootsFaces-OSP-default-theme'
from(sourceSets.main.output.classesDirs) {
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/*.css"

include "META-INF/licenses/**"
}

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":"https://www.bootsfaces.net"
)
}
}
defaultJar.dependsOn(jar,":gradleResources:buildResources")
defaultJar.onlyIf { (themes.size() > 0) }

//These Tasks automatically look for tasks called compileJava<ver>Java

task buildJava11Jar(type: Jar) {
archiveBaseName='BootsFaces-OSP-java11'
from(sourceSets.java11.output.classesDirs) {
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/**"
//include "META-INF/resources/bsf/css/*.css"

include "META-INF/licenses/**"
}

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":"https://www.bootsfaces.net"
)
}
}
buildJava11Jar.dependsOn(jar,":gradleResources:buildResources")
buildJava11Jar.onlyIf { (themes.size() > 0) && buildJava11==true }
//jar.onlyIf { buildJava11==true }

task buildJava17Jar(type: Jar) {
archiveBaseName='BootsFaces-OSP-java17'
from(sourceSets.java17.output.classesDirs) {
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/*.css"

include "META-INF/licenses/**"
}

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":"https://www.bootsfaces.net"
)
}
}
buildJava17Jar.dependsOn(jar,":gradleResources:buildResources")
buildJava17Jar.onlyIf { (themes.size() > 0) && buildJava11==true }

compileJava.doFirst {
println "INFO: Compiling the Java Sources:"
println "Gradle Runtime JVM version: "+ org.gradle.internal.jvm.Jvm.current().getJavaVersion().getMajorVersion().toInteger()
println "Java Toolchain Version :" + toolchainVersion
println "Java Build Options :" + buildOptsJava
println "sourceSets.main.java.srcDirs :" + sourceSets.main.java.srcDirs
println "sourceSets.main.output.classesDirs :" + sourceSets.main.output.classesDirs
println "sourceSets.main.output.resourcesDir :" + sourceSets.main.output.resourcesDir

}

defaultTasks 'clean','defaultJar','buildJava11Jar','buildJava17Jar','publishToMavenLocal'
Loading

0 comments on commit 734833d

Please sign in to comment.