Skip to content

Commit 71dbb8c

Browse files
committed
minor refactor
1 parent bcd3b52 commit 71dbb8c

File tree

16 files changed

+69
-68
lines changed

16 files changed

+69
-68
lines changed

docs/RunningGitpod.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Once loaded, run one of the available script tasks. To find
77
available script tasks you can try something like:
88

99
```
10-
> ./gradlew :HousePricesBeam:tasks --group="Scripts"
10+
> ./gradlew :HousePricesBeam:tasks --group="Application"
1111
```
1212

1313
You should see something like below:

docs/RunningLocal.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ For subprojects with multiple scripts, it will typically be "run" followed by th
4848
<summary>Linux/MacOS</summary>
4949

5050
<pre>
51-
$ <b>./gradlew :Candles:tasks --group="Script"</b>
51+
$ <b>./gradlew :Candles:tasks --group="Application"</b>
5252
> Task :Candles:tasks
5353

5454
------------------------------------------------------------
5555
Tasks runnable from project ':Candles'
5656
------------------------------------------------------------
5757

58-
Script tasks
59-
------------
58+
Application tasks
59+
-----------------
6060
runCandleRatings - Run CandleRatings.groovy as a JVM application/Groovy script
6161
runCandleReviews - Run CandleReviews.groovy as a JVM application/Groovy script
6262
...
@@ -67,7 +67,7 @@ $ <b>./gradlew :Candles:runCandleRatings</b>
6767
<summary>Windows</summary>
6868

6969
<pre>
70-
> <b>gradlew :Candles:tasks --group="Script"</b>
70+
> <b>gradlew :Candles:tasks --group="Application"</b>
7171
> Task :Candles:tasks
7272

7373
------------------------------------------------------------

subprojects/Candles/Candles.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ repositories {
2222
FileUtil.baseNames(sourceSets.main.allSource.files, ['TablesawHelper']).each { name ->
2323
tasks.register("run$name", JavaExec) {
2424
dependsOn compileGroovy
25-
group 'Script'
25+
group 'Application'
2626
description "Run ${name}.groovy as a JVM application/Groovy script"
2727
classpath = sourceSets.main.runtimeClasspath
2828
mainClass = name

subprojects/Candles/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ These examples are currently set up to run locally, either in your IDE or via th
5454

5555
Command-line arguments for Gradle to see the task names for running the Groovy scripts (use `./gradlew` on Unix-like systems):
5656
```
57-
gradlew :Candles:tasks --group="Script"
57+
gradlew :Candles:tasks --group="Application"
5858
```
5959

6060
Alternatively, you can use a Jupyter/Beakerx notebook:

subprojects/HousePrices/HousePrices.gradle

+18-37
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,14 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import static JavaFXUtil.checkForJavaFX
17-
1816
apply plugin: 'groovy'
1917

2018
repositories {
2119
mavenCentral()
2220
}
2321

24-
tasks.register('checkJdk8Compatibility') {
25-
doLast {
26-
assert JavaVersion.current().isJava8(), "JDK8 is required but found ${JavaVersion.current()}!"
27-
}
28-
}
29-
30-
ext.camel = JavaVersion.current().isJava8() ? camelLegacyVersion : camelVersion
31-
3222
dependencies {
33-
// Using Groovy 3 because GroovyFX examples require it
34-
implementation "org.codehaus.groovy:groovy:$groovy3Version"
23+
implementation "org.apache.groovy:groovy:$groovy4Version"
3524
implementation "nz.ac.waikato.cms.weka:weka-dev:$wekaVersion"
3625
implementation "com.opencsv:opencsv:$opencsvVersion"
3726
implementation "org.apache.commons:commons-csv:$commonsCsvVersion"
@@ -40,50 +29,42 @@ dependencies {
4029
implementation "org.knowm.xchart:xchart:$knowmXchartVersion"
4130
// https://web.archive.org/web/20140415021609/http://xeiam.com:80/xchart.jsp
4231
runtimeOnly 'com.xeiam.xchart:xchart:2.5.1' // older version of org.knowm.xchart:xchart
43-
implementation "org.slf4j:slf4j-jdk14:$slf4jVersion"
4432
implementation "tech.tablesaw:tablesaw-core:$tablesawVersion"
4533
implementation "tech.tablesaw:tablesaw-aggregate:$tablesawVersion"
4634
// runtime 'com.github.fommil.netlib:all:1.1.2'
4735
implementation "com.github.haifengl:smile-core:$smileVersion"
4836
implementation "com.github.haifengl:smile-math:$smileVersion"
4937
implementation "com.github.haifengl:smile-io:$smileVersion"
5038
implementation "com.github.haifengl:smile-plot:$smileVersion"
51-
implementation "org.tribuo:tribuo-all:$tribuoVersion"
39+
implementation "org.tribuo:tribuo-regression-libsvm:$tribuoVersion"
40+
implementation "org.tribuo:tribuo-regression-sgd:$tribuoVersion"
41+
implementation "org.tribuo:tribuo-regression-tree:$tribuoVersion"
42+
implementation "org.tribuo:tribuo-anomaly-libsvm:$tribuoVersion"
43+
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:$jacksonVersion"
5244
runtimeOnly "org.slf4j:slf4j-jdk14:$slf4jVersion"
5345
runtimeOnly "org.bytedeco:openblas-platform:$openblasPlatformVersion"
54-
if (JavaVersion.current().isJava8() && checkForJavaFX()) {
55-
implementation 'org.groovyfx:groovyfx:8.0.0'
46+
}
47+
48+
tasks.register('versionInfo') {
49+
doLast {
50+
File javaHome = new File(System.getProperty('java.home'))
51+
logger.lifecycle "Using Java from $javaHome (version ${JavaVersion.current()})"
5652
}
5753
}
5854

59-
tasks.withType(GroovyCompile).configureEach {
60-
if (!checkForJavaFX() || !JavaVersion.current().isJava8()) {
61-
exclude '**/*GroovyFX.groovy'
62-
exclude '**/FXCheck.groovy'
63-
doLast {
64-
println """
65-
********************************************************
66-
** Excluding GroovyFX scripts due to incompatible JDK **
67-
** ${ (JavaVersion.current().isJava8() ? "No JavaFX?" :
68-
"Expecting Java 8 but found ${JavaVersion.current()}").padRight(50) } **
69-
********************************************************
70-
""".stripIndent()
71-
}
55+
tasks.register('checkJdk17Compatibility') {
56+
doLast {
57+
assert JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17), "JDK17+ is required but found ${JavaVersion.current()}!"
7258
}
7359
}
7460

7561
FileUtil.baseNames(sourceSets.main.allSource.files).each { name ->
7662
tasks.register("run$name", JavaExec) {
77-
group 'Script'
78-
// current version of GroovyFX requires JDK8
79-
if (name.endsWith('GroovyFX')) dependsOn([checkJdk8Compatibility, 'runFXCheck'])
63+
group 'Application'
8064
description "Run ${name}.groovy as a JVM application/Groovy script"
8165
classpath = sourceSets.main.runtimeClasspath
8266
mainClass = name
83-
doLast {
84-
File javaHome = new File(System.getProperty('java.home'))
85-
logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
86-
if (name.contains('Camel')) logger.lifecycle "Using Camel version $camel"
87-
}
67+
dependsOn versionInfo
68+
if (name.endsWith('JDK17')) dependsOn checkJdk17Compatibility
8869
}
8970
}

subprojects/HousePrices/README.md

+16-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ limitations under the License.
1616

1717
# House price prediction with regression
1818

19+
<img src="../../docs/images/cottage.png" height="250" alt="house"/>
20+
21+
## Linear regression
22+
1923
Linear regression will enable us to find a "best fit" linear relationship between
2024
some properties or features of interest.
2125
Ordinary least squares finds such a relationship by minimising residual errors.
@@ -26,7 +30,8 @@ several CSV handling libraries and a number of visualization options.
2630

2731
![linear regression house prices](../../docs/images/houses.png)
2832

29-
Groovy code examples can be found in the [HousePrices](subprojects/HousePrices/src/main/groovy) subproject.
33+
Groovy code examples can be found in the [src/main/groovy](src/main/groovy) directory.
34+
3035
There are example scripts which:
3136
* read from CSV files (multiple technologies)
3237
* explore finding outliers
@@ -43,7 +48,7 @@ You have several options for running the programs (see more details from the mai
4348
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/paulk-asert/groovy-data-science/master?filepath=subprojects%2FHousePrices%2Fsrc%2Fmain%2Fnotebook%2FHousePrices.ipynb)
4449

4550
* From the command line, invoke a script with gradlew using the appropriate run&lt;_ScriptName_&gt; task.
46-
(Hint: `gradlew :HousePrices:tasks --group="Script"` will show you available task names.)
51+
(Hint: `gradlew :HousePrices:tasks --group="Application"` will show you available task names.)
4752
* If the example has @Grab statements commented out at the top, you can cut and paste the examples into the groovyConsole
4853
and uncomment the grab statements. Make sure to cut and paste any helper classes too if appropriate.
4954

@@ -67,18 +72,22 @@ Some regression algorithm variants like stochastic gradient descent are amenable
6772
And some frameworks support such algorithms. The following subprojects highlight frameworks
6873
with special support for scaling linear regression:
6974

70-
* The [HousePricesIgnite](subprojects/HousePricesIgnite/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Ignite. It has been tested on JDK8, JDK11 and JDK17.
75+
* The [HousePricesIgnite](../HousePricesIgnite/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Ignite. It has been tested on JDK8, JDK11 and JDK17.
7176

72-
* The [HousePricesSpark](subprojects/HousePricesSpark/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Spark. It has been tested on JDK8 and JDK11. The current Spark versions are not compatible with JDK17.
77+
* The [HousePricesSpark](../HousePricesSpark/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Spark. It has been tested on JDK8 and JDK11. The current Spark versions are not compatible with JDK17.
7378

7479
If you find that your algorithm isn't directly amenable to scaling
7580
you can often tweak it or apply it in some fashion to ensure certain
7681
constraints hold. This can enable you to still scale up.
7782
The following subprojects highlight tweaking linear regression
7883
for scaling purposes:
7984

80-
* The [HousePricesBeam](subprojects/HousePricesBeam/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Beam. It has been tested on JDK8, JDK11 and JDK17.
85+
* The [HousePricesBeam](../HousePricesBeam/src/main/groovy) subproject which illustrates scaling up to a cluster using Apache Beam. It has been tested on JDK8, JDK11 and JDK17.
86+
87+
* The [HousePricesGPars](../HousePricesGPars/src/main/groovy) subproject which illustrates scaling up concurrently using GPars. It has been tested on JDK8, JDK11 and JDK17.
8188

82-
* The [HousePricesGPars](subprojects/HousePricesGPars/src/main/groovy) subproject which illustrates scaling up concurrently using GPars. It has been tested on JDK8, JDK11 and JDK17.
89+
When collecting data, it can be useful to use special purpose integration technologies:
8390

84-
When collecting data, it can be useful to use integration technologies like Apache Camel. The `ExploreOutlier_ApacheCamelCSV` example illustrates gathering data and finding outliers using this technology. This example works on JDK8, JDK11 and JDK17. An older version of Apache Camel is used on JDK8.
91+
* The [HousePricesCamel](../HousePricesCamel/src/main/groovy) subproject
92+
illustrates gathering data and finding outliers using Apache Camel.
93+
* It has been tested on JDK8, JDK11 and JDK17.

subprojects/HousePricesGPars/HousePricesGPars.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ sourceCompatibility = 1.8
2020
FileUtil.baseNames(sourceSets.main.allSource.files).each { name ->
2121
tasks.register("run$name", JavaExec) {
2222
dependsOn compileGroovy
23-
group 'Script'
23+
group 'Application'
2424
description "Run ${name}.groovy as a JVM application/Groovy script"
2525
classpath = sourceSets.main.runtimeClasspath
2626
mainClass = name

subprojects/Iris/Iris.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ tasks.register('checkJavaFXCompatibility') {
115115

116116
FileUtil.baseNames(sourceSets.main.allSource.files, ['InstallWekaPackages']).each { name ->
117117
tasks.register("run$name", JavaExec) {
118-
group 'Script'
118+
group 'Application'
119119
if (name.contains('Datumbox')) dependsOn(checkJdk11Compatibility)
120120
if (name.contains('JavaFX') && !JavaVersion.current().java11Compatible) dependsOn(checkJavaFXCompatibility)
121121
description "Run ${name}.groovy as a JVM application/Groovy script"

subprojects/Iris/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ You have several options for running the programs (see more details from the mai
6666
* If you have opened the repo in IntelliJ (or your favourite IDE) you should be able to execute the examples directly in the IDE.
6767

6868
* From the command line, invoke a script with gradlew using the appropriate run&lt;_ScriptName_&gt; task.
69-
(Hint: `gradlew :Iris:tasks --group="Script"` will show you available task names.)
69+
(Hint: `gradlew :Iris:tasks --group="Application"` will show you available task names.)
7070

7171
* You can run the main examples online using a Jupyter/Beakerx notebook:
7272
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/paulk-asert/groovy-data-science/HEAD?filepath=subprojects%2FIris%2Fsrc%2Fmain%2Fnotebook%2FIris.ipynb)

subprojects/LanguageProcessing/LanguageProcessing.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ tasks.register('checkJdk8Exactly') {
5454

5555
FileUtil.baseNames(sourceSets.main.allSource.files, ['ResourceHelper']).each { name ->
5656
tasks.register("run$name", JavaExec) {
57-
group 'Script'
57+
group 'Application'
5858
dependsOn compileGroovy
5959
if (name.endsWith('JDK11')) dependsOn(checkJdk11Compatibility)
6060
if (name.endsWith('JDK8only')) dependsOn(checkJdk8Exactly)

subprojects/LanguageProcessing/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You have several options for running the programs (see more details from the mai
3131
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/paulk-asert/groovy-data-science/master?filepath=subprojects%2FLanguageProcessing%2Fsrc%2Fmain%2Fnotebook%2FLanguageProcessing.ipynb)
3232

3333
* From the command line, invoke a script with gradlew using the appropriate run&lt;_ScriptName_&gt; task.\
34-
(Hint: `gradlew :LanguageProcessing:tasks --group="Script"` will show you available task names.)
34+
(Hint: `gradlew :LanguageProcessing:tasks --group="Application"` will show you available task names.)
3535

3636
* If the example has @Grab statements commented out at the top, you can cut and paste the examples into the groovyConsole
3737
and uncomment the grab statements. Make sure to cut and paste any helper classes too if appropriate.

subprojects/Mnist/Mnist.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ FileUtil.baseNames(sourceSets.main.allSource.files, ['MnistInfer', 'MnistReader'
6666
tasks.register("run$name", JavaExec) {
6767
// current version of GroovyFX requires JDK8
6868
if (name.endsWith('Gui')) dependsOn([checkJdk8Compatibility, checkJavaFXCompatibility])
69-
group 'Script'
69+
group 'Application'
7070
description "Run ${name}.groovy as a JVM application/Groovy script"
7171
classpath = sourceSets.main.runtimeClasspath
7272
mainClass = name

subprojects/Whiskey/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You have several options for running the programs (see more details from the mai
4040
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/paulk-asert/groovy-data-science/master?filepath=subprojects%2FWhiskey%2Fsrc%2Fmain%2Fnotebook%2FWhiskey.ipynb)
4141

4242
* From the command line, invoke a script with gradlew using the appropriate run&lt;_ScriptName_&gt; task.\
43-
(Hint: `gradlew :Whiskey:tasks --group="Script"` will show you available task names.)
43+
(Hint: `gradlew :Whiskey:tasks --group="Application"` will show you available task names.)
4444
* If the example has @Grab statements commented out at the top, you can cut and paste the examples into the groovyConsole
4545
and uncomment the grab statements. Make sure to cut and paste any helper classes too if appropriate.
4646

subprojects/Whiskey/Whiskey.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FileUtil.baseNames(sourceSets.main.allSource.files, ['InstallWekaPackages']).eac
3636
tasks.register("run$name", JavaExec) {
3737
dependsOn compileGroovy
3838
if (name.contains('Datumbox')) dependsOn(checkJdk11Compatibility)
39-
group 'Script'
39+
group 'Application'
4040
description "Run ${name}.groovy as a JVM application/Groovy script"
4141
classpath = sourceSets.main.runtimeClasspath
4242
mainClass = name

subprojects/WhiskeyIgnite/WhiskeyIgnite.gradle

+9-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ repositories {
2525
// }
2626
}
2727

28+
ext.appName = 'WhiskeyIgnite'
29+
2830
application {
29-
mainClass = 'WhiskeyIgnite'
31+
mainClass = appName
3032
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
3133
applicationDefaultJvmArgs = [
3234
'--add-opens=java.base/java.io=ALL-UNNAMED',
@@ -37,6 +39,10 @@ application {
3739
}
3840
}
3941

42+
tasks.named('run').configure {
43+
description = "Run $appName as a JVM application/Groovy script"
44+
}
45+
4046
dependencies {
4147
implementation "org.apache.groovy:groovy:$groovy4Version"
4248
implementation "org.apache.ignite:ignite-core:$igniteVersion"
@@ -46,11 +52,11 @@ dependencies {
4652
implementation "tech.tablesaw:tablesaw-core:$tablesawVersion"
4753
}
4854

49-
tasks.register('jdkVersion') {
55+
tasks.register('versionInfo') {
5056
doLast {
5157
File javaHome = new File(System.getProperty('java.home'))
5258
logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
5359
}
5460
}
5561

56-
run.dependsOn jdkVersion
62+
run.dependsOn versionInfo

subprojects/WhiskeySpark/WhiskeySpark.gradle

+11-6
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,33 @@ repositories {
2121
// mavenLocal()
2222
}
2323

24-
application {
25-
mainClass = 'WhiskeySpark'
26-
}
27-
2824
ext {
25+
appName = 'WhiskeySpark'
2926
sparkVariant = '2.12'
3027
sparkVersion = '3.3.0'
3128
}
3229

30+
application {
31+
mainClass = appName
32+
}
33+
34+
tasks.named('run').configure {
35+
description = "Run $appName as a JVM application/Groovy script"
36+
}
37+
3338
dependencies {
3439
implementation "org.apache.groovy:groovy:$groovy4Version"
3540
implementation "org.apache.spark:spark-core_$sparkVariant:$sparkVersion"
3641
implementation "org.apache.spark:spark-sql_$sparkVariant:$sparkVersion"
3742
implementation "org.apache.spark:spark-mllib_$sparkVariant:$sparkVersion"
3843
}
3944

40-
tasks.register('jdkVersion') {
45+
tasks.register('versionInfo') {
4146
doLast {
4247
File javaHome = new File(System.getProperty('java.home'))
4348
logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
4449
assert JavaVersion.current().isJava8() || JavaVersion.current().isJava11(), "JDK8 or JDK11 is required but found ${JavaVersion.current()}!"
4550
}
4651
}
4752

48-
run.dependsOn jdkVersion
53+
run.dependsOn versionInfo

0 commit comments

Comments
 (0)