-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gradle Build rewrite to improve efficiency, drop legacy Java and buil…
…d only LTS runtimes.
- Loading branch information
1 parent
40d872e
commit 734833d
Showing
4 changed files
with
324 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Oops, something went wrong.