@@ -90,71 +90,108 @@ subprojects {
9090 ' -Ywarn-adapted-args'
9191 ]
9292
93- tasks. withType(ScalaCompile ) {
93+ tasks. withType(ScalaCompile ). configureEach {
9494 options. encoding = ' UTF-8'
9595 scalaCompileOptions. additionalParameters = scalacParameters
9696 }
9797
98- tasks. withType(ScalaDoc ) {
98+ tasks. withType(ScalaDoc ). configureEach {
9999 scalaDocOptions. additionalParameters = scalacParameters
100100 }
101101
102- task sourceJar( type : Jar ) {
102+ tasks . register( ' sourceJar ' , Jar ) {
103103 archiveClassifier = ' sources'
104104 from(sourceSets. main. allSource)
105105 }
106106
107- task docJar( type : Jar ) {
107+ tasks . register( ' docJar ' , Jar ) {
108108 dependsOn tasks. scaladoc
109109 archiveClassifier = ' javadoc'
110110 from(tasks. scaladoc. destinationDir)
111111 }
112112
113- task testJar( type : Jar ) {
113+ tasks . register( ' testJar ' , Jar ) {
114114 archiveClassifier = ' tests'
115115 from(sourceSets. test. output)
116116 }
117117
118- tasks. withType(Jar ) {
118+ tasks. withType(Jar ). configureEach {
119119 from(tasks. generateLicensesFiles) {
120120 into(" META-INF/" )
121121 }
122122 }
123123
124- task licenseFile {
124+ tasks . register( ' licenseFile' ) {
125125 outputs. file(project. parent. file(' LICENSE.txt' ))
126126 }
127127
128- task dependencySearch( type : DependencyInsightReportTask ) {
128+ tasks . register( ' dependencySearch ' , DependencyInsightReportTask ) {
129129 description = ' Searches all projects for a dependency'
130130 group = ' help'
131131 }
132132
133- task runApp {
133+ // TODO: it looks like this is only used for `:morpheus-examples` - we don't need it for all sub-projects 🤔
134+ // see: README.md:163
135+ tasks. register(' runApp' , JavaExec ) {
134136 dependsOn tasks. classes
135137 group = ' run'
136138 description = ' Run a custom Scala app (use -PmainClass=com.my.package.App)'
137- doLast {
138- javaexec {
139- classpath = sourceSets. main. runtimeClasspath
140- main = project. getProperty(" mainClass" )
141- }
142- }
139+
140+ classpath = sourceSets. main. runtimeClasspath
141+ mainClass = project. getProperty(" mainClass" )
142+ }
143+
144+ tasks. named(' runApp' ). configure {
145+ jvmArgs = [
146+ ' -Xmx2g' ,
147+ ' -Dconfig.file=app.conf' ,
148+ ' -XX:+IgnoreUnrecognizedVMOptions' ,
149+ ' --add-exports=java.base/sun.nio.ch=ALL-UNNAMED' ,
150+ ' --add-opens=java.base/java.lang.invoke=ALL-UNNAMED' ,
151+ ' --add-opens=java.base/java.lang=ALL-UNNAMED' ,
152+ ' --add-opens=java.base/java.lang.invoke=ALL-UNNAMED' ,
153+ ' --add-opens=java.base/java.lang.reflect=ALL-UNNAMED' ,
154+ ' --add-opens=java.base/java.io=ALL-UNNAMED' ,
155+ ' --add-opens=java.base/java.net=ALL-UNNAMED' ,
156+ ' --add-opens=java.base/java.nio=ALL-UNNAMED' ,
157+ ' --add-opens=java.base/java.util=ALL-UNNAMED' ,
158+ ' --add-opens=java.base/java.util.concurrent=ALL-UNNAMED' ,
159+ ' --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED' ,
160+ ' --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED' ,
161+ ' --add-opens=java.base/sun.nio.ch=ALL-UNNAMED' ,
162+ ' --add-opens=java.base/sun.nio.cs=ALL-UNNAMED' ,
163+ ' --add-opens=java.base/sun.security.action=ALL-UNNAMED' ,
164+ ' --add-opens=java.base/sun.util.calendar=ALL-UNNAMED' ,
165+ ' --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED' ,
166+ ' -Djdk.reflect.useDirectMethodHandle=false'
167+ ]
143168 }
144169
145170 // copied from https://stackoverflow.com/a/38058671/568723
146- task depSize {
171+ tasks . register( ' depSize' ) {
147172 description = ' Lists all dependencies sorted by their size'
173+
174+ doFirst {
175+ configurations {
176+ resolvableDefault {
177+ extendsFrom configurations. default
178+ canBeResolved = true
179+ canBeConsumed = false
180+ description = ' Resolvable default configuration.'
181+ }
182+ }
183+ }
184+
148185 doLast {
149186 final formatStr = " %,10.2f"
150- final conf = configurations. default
187+ final conf = configurations. resolvableDefault
151188 final size = conf. collect { it. length() / (1024 * 1024 ) }. sum()
152189 final out = new StringBuffer ()
153- out << ' Total dependencies size:' . padRight(45 )
190+ out << ' Total dependencies size:' . padRight(65 )
154191 out << " ${ String.format(formatStr, size)} Mb\n\n "
155192 conf. sort { - it. length() }
156193 .each {
157- out << " ${ it.name} " . padRight(45 )
194+ out << " ${ it.name} " . padRight(65 )
158195 out << " ${ String.format(formatStr, (it.length() / 1024))} kb\n "
159196 }
160197 println (out)
0 commit comments