11plugins {
2- id ' java-library '
3- id ' scala '
4- id ' com.github.hierynomus.license ' version ' 0.16.3-63da64d ' apply false
5- id ' com.gradleup.shadow ' version ' 9.2.2 ' apply false
6- id ' com.github.alisiikh. scalastyle' version ' 3.5.0 ' apply false
7- id ' me.champeau.jmh ' version ' 0.7.3 ' apply false
8- id " ch.kk7 .spawn" version " 1.0.20180924200750 " apply false
2+ id ' buildlogic.scala-application-conventions '
3+
4+ alias(libs . plugins . champeau . jmh) . apply( false )
5+ alias(libs . plugins . licencs) . apply( false )
6+ alias(libs . plugins . scalastyle) . apply( false )
7+ alias(libs . plugins . shadowjar) . apply( false )
8+ alias(libs . plugins . spawn) . apply( false )
99}
1010
1111apply from : ' build.params.gradle'
1212apply plugin : ' base'
1313
14+ configurations {
15+ resolvableRuntimeClasspath {
16+ extendsFrom configurations. runtimeClasspath
17+ canBeResolved = true
18+ canBeConsumed = false
19+ description = ' Resolvable runtime classpath configuration.'
20+ }
21+ }
22+
23+
1424allprojects {
1525 java {
16- sourceCompatibility = ver . jvm
17- targetCompatibility = ver . jvm
26+ sourceCompatibility = 21
27+ targetCompatibility = 21
1828 }
1929
2030 scala {
@@ -37,21 +47,21 @@ subprojects {
3747 }
3848
3949 dependencies {
40- implementation group : ' org .scala-lang ' , name : ' scala-library ' , version : ver . scala . full
50+ implementation libs . scala. library
4151
4252 // Seems we need to lock these down, otherwise we get runtime errors on reflection
43- implementation group : ' org .scala-lang ' , name : ' scala-reflect ' , version : ver . scala . full
44- implementation group : ' org .scala-lang ' , name : ' scala-compiler ' , version : ver . scala . full
45-
46- implementation group : ' org.apache.logging. log4j' , name : ' log4j-api ' , version : ver . log4j . main
47- implementation group : ' org.apache.logging. log4j' , name : " log4j-api-scala " . scala(), version : ver . log4j . scala
48-
49- testImplementation group : ' org.apache.logging. log4j' , name : ' log4j-core ' , version : ver . log4j . main
50- testImplementation group : ' org.scalatest ' , name : " scalatest " . scala(), version : ver . scalatest
51- testImplementation group : ' org.scalacheck ' , name : " scalacheck " . scala(), version : ver . scalacheck
52- testImplementation group : ' junit ' , name : ' junit ' , version : ver . junit. main
53- testImplementation group : ' org.mockito ' , name : ' mockito-all ' , version : ver . mockito
54- testRuntimeOnly group : ' org.junit.platform ' , name : ' junit-platform-runner ' , version : ver . junit. runner
53+ implementation libs . scala. compiler
54+ implementation libs . scala. reflect
55+
56+ implementation libs . log4j. api
57+ implementation libs . log4j. api . scala
58+
59+ testImplementation libs . log4j. core
60+ testImplementation libs . scalatest
61+ testImplementation libs . scalacheck
62+ testImplementation libs . junit
63+ testImplementation libs . mockito
64+ testRuntimeOnly libs . junit. runner
5565 }
5666
5767 test {
@@ -68,47 +78,72 @@ subprojects {
6878 ' -Ywarn-adapted-args'
6979 ]
7080
71- tasks. withType(ScalaCompile ) {
81+ tasks. withType(Test ). configureEach {
82+ // JVM args required by spark (see org.apache.spark.launcher.JavaModuleOptions)
83+ jvmArgs(
84+ ' -XX:+IgnoreUnrecognizedVMOptions' ,
85+ ' --add-exports=java.base/sun.nio.ch=ALL-UNNAMED' ,
86+ ' --add-opens=java.base/java.lang.invoke=ALL-UNNAMED' ,
87+ ' --add-opens=java.base/java.lang=ALL-UNNAMED' ,
88+ ' --add-opens=java.base/java.lang.invoke=ALL-UNNAMED' ,
89+ ' --add-opens=java.base/java.lang.reflect=ALL-UNNAMED' ,
90+ ' --add-opens=java.base/java.io=ALL-UNNAMED' ,
91+ ' --add-opens=java.base/java.net=ALL-UNNAMED' ,
92+ ' --add-opens=java.base/java.nio=ALL-UNNAMED' ,
93+ ' --add-opens=java.base/java.util=ALL-UNNAMED' ,
94+ ' --add-opens=java.base/java.util.concurrent=ALL-UNNAMED' ,
95+ ' --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED' ,
96+ ' --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED' ,
97+ ' --add-opens=java.base/sun.nio.ch=ALL-UNNAMED' ,
98+ ' --add-opens=java.base/sun.nio.cs=ALL-UNNAMED' ,
99+ ' --add-opens=java.base/sun.security.action=ALL-UNNAMED' ,
100+ ' --add-opens=java.base/sun.util.calendar=ALL-UNNAMED' ,
101+ ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED' ,
102+ ' -Djdk.reflect.useDirectMethodHandle=false'
103+ )
104+ }
105+
106+ tasks. withType(ScalaCompile ). configureEach {
72107 options. encoding = ' UTF-8'
73108 scalaCompileOptions. additionalParameters = scalacParameters
74109 }
75110
76- tasks. withType(ScalaDoc ) {
111+ tasks. withType(ScalaDoc ). configureEach {
77112 scalaDocOptions. additionalParameters = scalacParameters
78113 }
79114
80- task sourceJar( type : Jar ) {
115+ tasks . register( ' sourceJar ' , Jar ) {
81116 archiveClassifier = ' sources'
82117 from(sourceSets. main. allSource)
83118 }
84119
85- task docJar( type : Jar ) {
120+ tasks . register( ' docJar ' , Jar ) {
86121 dependsOn tasks. scaladoc
87122 archiveClassifier = ' javadoc'
88123 from(tasks. scaladoc. destinationDir)
89124 }
90125
91- task testJar( type : Jar ) {
126+ tasks . register( ' testJar ' , Jar ) {
92127 archiveClassifier = ' tests'
93128 from(sourceSets. test. output)
94129 }
95130
96- tasks. withType(Jar ) {
131+ tasks. withType(Jar ). configureEach {
97132 from(tasks. generateLicensesFiles) {
98133 into(" META-INF/" )
99134 }
100135 }
101136
102- task licenseFile {
137+ tasks . register( ' licenseFile' ) {
103138 outputs. file(project. parent. file(' LICENSE.txt' ))
104139 }
105140
106- task dependencySearch( type : DependencyInsightReportTask ) {
141+ tasks . register( ' dependencySearch ' , DependencyInsightReportTask ) {
107142 description = ' Searches all projects for a dependency'
108143 group = ' help'
109144 }
110145
111- task runApp {
146+ tasks . register( ' runApp' ) {
112147 dependsOn tasks. classes
113148 group = ' run'
114149 description = ' Run a custom Scala app (use -PmainClass=com.my.package.App)'
@@ -120,12 +155,20 @@ subprojects {
120155 }
121156 }
122157
158+ configurations {
159+ resolvableDefault {
160+ extendsFrom configurations. default
161+ canBeResolved = true
162+ canBeConsumed = false
163+ description = ' Resolvable default configuration.'
164+ }
165+ }
123166 // copied from https://stackoverflow.com/a/38058671/568723
124- task depSize {
167+ tasks . register( ' depSize' ) {
125168 description = ' Lists all dependencies sorted by their size'
126169 doLast {
127170 final formatStr = " %,10.2f"
128- final conf = configurations. default
171+ final conf = configurations. resolvableDefault
129172 final size = conf. collect { it. length() / (1024 * 1024 ) }. sum()
130173 final out = new StringBuffer ()
131174 out << ' Total dependencies size:' . padRight(45 )
0 commit comments