Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): make Gradle less noisy #5700

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix Idea-reported problems
  • Loading branch information
yuri1969 committed Oct 28, 2024
commit 98224b488cb5046bddfd02318a506fc213e0ce64
38 changes: 22 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import net.e175.klaus.zip.ZipPrefixer
import org.owasp.dependencycheck.gradle.extension.AnalyzerExtension

buildscript {
repositories {
Expand Down Expand Up @@ -325,9 +326,12 @@ dependencyCheck {
failBuildOnCVSS = 7

// disable the .NET assembly analyzer as otherwise it wants to analyze EXE file
analyzers {
assemblyEnabled = false
}
analyzers(new Action<AnalyzerExtension>() {
@Override
void execute(AnalyzerExtension analyzerExtension) {
analyzerExtension.assemblyEnabled = false
}
})

// configure a suppression file
suppressionFile = "$projectDir/owasp-dependency-suppressions.xml"
Expand All @@ -340,7 +344,7 @@ dependencyCheck {
**********************************************************************************************************************/
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Xlint:all")
Expand All @@ -349,7 +353,7 @@ allprojects {
}
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
}
Expand Down Expand Up @@ -394,20 +398,21 @@ shadowJar.dependsOn 'ui:assembleFrontend'
/**********************************************************************************************************************\
* Executable Jar
**********************************************************************************************************************/
def executableDir = file("${buildDir}/executable")
def executable = file("${buildDir}/executable/${project.name}-${project.version}")
def executableDir = layout.buildDirectory.dir("executable")
def executable = layout.buildDirectory.file("executable/${project.name}-${project.version}").get().asFile

task writeExecutableJar() {
tasks.register('writeExecutableJar') {
group "build"
description "Write an executable jar from shadow jar"
dependsOn = [shadowJar]

doFirst {
executableDir.mkdirs()
executableDir.get().asFile.mkdirs()
}

doLast {
executable.setBytes(file("${buildDir}/libs/${project.name}-${project.version}.jar").readBytes())
final shadowJar = layout.buildDirectory.file("libs/${project.name}-${project.version}.jar")
executable.setBytes(shadowJar.get().asFile.readBytes())
ByteArrayOutputStream executableBytes = new ByteArrayOutputStream()
executableBytes.write("\n: <<END_OF_KESTRA_SELFRUN\r\n".getBytes())
executableBytes.write(file("gradle/jar/selfrun.bat").readBytes())
Expand All @@ -419,13 +424,13 @@ task writeExecutableJar() {
}
}

task executableJar(type: Zip) {
tasks.register('executableJar', Zip) {
group "build"
description "Zip the executable jar"
dependsOn = [writeExecutableJar]

archiveFileName = "${project.name}-${project.version}.zip"
destinationDirectory = file("${buildDir}/archives")
destinationDirectory = layout.buildDirectory.dir('archives')

from executableDir
archiveClassifier.set(null)
Expand All @@ -434,8 +439,9 @@ task executableJar(type: Zip) {
/**********************************************************************************************************************\
* Standalone
**********************************************************************************************************************/
task runLocal(type: JavaExec) {
tasks.register('runLocal', JavaExec) {
group = "application"
description = "Run Kestra as server local"
classpath = project(":cli").sourceSets.main.runtimeClasspath
mainClass = mainClassName
environment 'MICRONAUT_ENVIRONMENTS', 'override'
Expand Down Expand Up @@ -470,7 +476,7 @@ subprojects {
}
}

task sourcesJar(type: Jar) {
tasks.register('sourcesJar', Jar) {
dependsOn = [':core:copyGradleProperties']
dependsOn = [':ui:assembleFrontend']
archiveClassifier.set('sources')
Expand All @@ -479,12 +485,12 @@ subprojects {
sourcesJar.dependsOn ':core:copyGradleProperties'
sourcesJar.dependsOn ':ui:assembleFrontend'

task javadocJar(type: Jar) {
tasks.register('javadocJar', Jar) {
archiveClassifier.set('javadoc')
from javadoc
}

task testsJar(type: Jar) {
tasks.register('testsJar', Jar) {
archiveClassifier.set('tests')
from sourceSets.test.output
}
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ configurations {
implementation.extendsFrom(micronaut)
}

task copyGradleProperties(type: Copy) {
tasks.register('copyGradleProperties', Copy) {
group = "build"
shouldRunAfter compileJava

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
/**********************************************************************************************************************\
* ./gradlew playwright
**********************************************************************************************************************/
task playwright(type: JavaExec) {
tasks.register('playwright', JavaExec) {
classpath sourceSets.test.runtimeClasspath
mainClass = 'com.microsoft.playwright.CLI'
}
Expand Down