From 97836e18b2d90b08d6f789ca7ab0e74534da36ed Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 30 Oct 2021 12:01:52 +0200 Subject: [PATCH] simplified gradle config, automatically run installDist task after build --- build.gradle | 9 ++++++++- codeGeneration/build.gradle | 25 ++++-------------------- codeOptimizers/build.gradle | 25 ++++-------------------- compiler/build.gradle | 33 +++++++------------------------- compilerAst/build.gradle | 25 ++++-------------------- compilerInterfaces/build.gradle | 25 ++++-------------------- dbusCompilerService/build.gradle | 30 +++++++---------------------- docs/source/building.rst | 8 ++++---- gradle.properties | 2 ++ httpCompilerService/build.gradle | 31 +++++++----------------------- parser/build.gradle | 9 ++++----- 11 files changed, 55 insertions(+), 167 deletions(-) diff --git a/build.gradle b/build.gradle index b048f783a..bb2e98f9c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,10 @@ plugins { - id "org.jetbrains.kotlin.jvm" version "1.5.30" apply false + id "org.jetbrains.kotlin.jvm" version "$kotlinVersion" apply false +} + +allprojects { + repositories { + mavenLocal() + mavenCentral() + } } diff --git a/codeGeneration/build.gradle b/codeGeneration/build.gradle index 9598063ac..aa57491c2 100644 --- a/codeGeneration/build.gradle +++ b/codeGeneration/build.gradle @@ -5,13 +5,10 @@ plugins { id "org.jetbrains.kotlin.jvm" } -targetCompatibility = 11 -sourceCompatibility = 11 - -repositories { - mavenLocal() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } } dependencies { @@ -28,20 +25,6 @@ dependencies { } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - sourceSets { main { java { diff --git a/codeOptimizers/build.gradle b/codeOptimizers/build.gradle index 0cedf5d3b..52e4faeae 100644 --- a/codeOptimizers/build.gradle +++ b/codeOptimizers/build.gradle @@ -5,13 +5,10 @@ plugins { id "org.jetbrains.kotlin.jvm" } -targetCompatibility = 11 -sourceCompatibility = 11 - -repositories { - mavenLocal() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } } dependencies { @@ -27,20 +24,6 @@ dependencies { } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - sourceSets { main { java { diff --git a/compiler/build.gradle b/compiler/build.gradle index b063fde52..543209b9c 100644 --- a/compiler/build.gradle +++ b/compiler/build.gradle @@ -5,13 +5,13 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.0' } -targetCompatibility = 11 -sourceCompatibility = 11 - +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } +} repositories { - mavenLocal() - mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } } @@ -47,22 +47,6 @@ configurations { } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - useIR = true - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - useIR = true - } -} - sourceSets { main { java { @@ -87,11 +71,6 @@ application { applicationName = 'p8compile' } -artifacts { - archives shadowJar -} - - shadowJar { archiveBaseName = 'prog8compiler' archiveVersion = prog8version @@ -111,3 +90,5 @@ test { events "skipped", "failed" } } + +build.finalizedBy installDist, installShadowDist diff --git a/compilerAst/build.gradle b/compilerAst/build.gradle index 8eeb093e9..914a217f2 100644 --- a/compilerAst/build.gradle +++ b/compilerAst/build.gradle @@ -3,14 +3,13 @@ plugins { id "org.jetbrains.kotlin.jvm" } -targetCompatibility = 11 -sourceCompatibility = 11 -repositories { - mavenCentral() +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } } - dependencies { implementation 'org.antlr:antlr4-runtime:4.9.2' implementation "com.michael-bull.kotlin-result:kotlin-result-jvm:1.1.12" @@ -26,22 +25,6 @@ configurations.all { exclude group: 'com.ibm.icu', module: 'icu4j' } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - useIR = true - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - useIR = true - } -} - sourceSets { main { java { diff --git a/compilerInterfaces/build.gradle b/compilerInterfaces/build.gradle index 0499bfdff..dc55d631d 100644 --- a/compilerInterfaces/build.gradle +++ b/compilerInterfaces/build.gradle @@ -5,13 +5,10 @@ plugins { id "org.jetbrains.kotlin.jvm" } -targetCompatibility = 11 -sourceCompatibility = 11 - -repositories { - mavenLocal() - mavenCentral() - maven { url "https://kotlin.bintray.com/kotlinx" } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } } dependencies { @@ -26,20 +23,6 @@ dependencies { } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - sourceSets { main { java { diff --git a/dbusCompilerService/build.gradle b/dbusCompilerService/build.gradle index 846dc15ff..19a69e094 100644 --- a/dbusCompilerService/build.gradle +++ b/dbusCompilerService/build.gradle @@ -6,12 +6,13 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.0' } -targetCompatibility = 11 -sourceCompatibility = 11 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } +} repositories { - mavenLocal() - mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } } @@ -33,20 +34,6 @@ configurations.all { exclude group: "org.antlr", module: "antlr4" } -compileKotlin { - kotlinOptions { - jvmTarget = "11" - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - sourceSets { main { java { @@ -70,11 +57,6 @@ application { applicationName = 'prog8compilerservicedbus' } -artifacts { - archives shadowJar -} - - shadowJar { archiveBaseName = 'prog8compilerservicedbus' archiveVersion = '1.0' @@ -94,3 +76,5 @@ test { events "skipped", "failed" } } + +build.finalizedBy installDist, installShadowDist diff --git a/docs/source/building.rst b/docs/source/building.rst index f1dc5df90..c2fb00c55 100644 --- a/docs/source/building.rst +++ b/docs/source/building.rst @@ -21,8 +21,9 @@ Then you can choose a few ways to get a compiler: The Gradle build system is used to build the compiler. The most interesting gradle commands to run are probably: - ``./gradlew check`` + ``./gradlew build`` Builds the compiler code and runs all available checks and unit-tests. + Also automatically runs the installDist and installShadowDist tasks. ``./gradlew installDist`` Builds the compiler and installs it with scripts to run it, in the directory ``./compiler/build/install/p8compile`` @@ -34,8 +35,7 @@ The most interesting gradle commands to run are probably: Creates a zipfile with the above in it, for easy distribution. This file can be found in ``./compiler/build/distributions/`` -For normal use, the ``installDist`` target should suffice and ater succesful completion -of that build task, you can start the compiler with: +For normal use, the ``installDist`` target should suffice and after succesful completion, you can start the compiler with: ``./compiler/build/install/p8compile/bin/p8compile `` @@ -44,7 +44,7 @@ of that build task, you can start the compiler with: .. hint:: Development and testing is done on Linux using the IntelliJ IDEA IDE, but the compiler should run on most operating systems that provide a fairly modern - java runtime. If you do have trouble building or running the compiler on your + java runtime (11 or newer). If you do have trouble building or running the compiler on your operating system, please let me know! diff --git a/gradle.properties b/gradle.properties index da410ff62..f57692e94 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,3 +3,5 @@ org.gradle.console=rich org.gradle.parallel=true org.gradle.daemon=true kotlin.code.style=official +javaVersion=11 +kotlinVersion=1.5.30 diff --git a/httpCompilerService/build.gradle b/httpCompilerService/build.gradle index 8926488b3..e3cf85838 100644 --- a/httpCompilerService/build.gradle +++ b/httpCompilerService/build.gradle @@ -6,12 +6,13 @@ plugins { id 'com.github.johnrengelman.shadow' version '7.1.0' } -targetCompatibility = 11 -sourceCompatibility = 11 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } +} repositories { - mavenLocal() - mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } } @@ -37,21 +38,6 @@ configurations.all { exclude group: "org.antlr", module: "antlr4" } - -compileKotlin { - kotlinOptions { - jvmTarget = "11" - // verbose = true - // freeCompilerArgs += "-XXLanguage:+NewInference" - } -} - -compileTestKotlin { - kotlinOptions { - jvmTarget = "11" - } -} - sourceSets { main { java { @@ -75,11 +61,6 @@ application { applicationName = 'prog8compilerservicehttp' } -artifacts { - archives shadowJar -} - - shadowJar { archiveBaseName = 'prog8compilerservicehttp' archiveVersion = '1.0' @@ -99,3 +80,5 @@ test { events "skipped", "failed" } } + +build.finalizedBy installDist, installShadowDist diff --git a/parser/build.gradle b/parser/build.gradle index c97ce6684..2d201d88d 100644 --- a/parser/build.gradle +++ b/parser/build.gradle @@ -3,11 +3,10 @@ plugins { id 'java' } -targetCompatibility = 11 -sourceCompatibility = 11 - -repositories { - mavenCentral() +java { + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + } } dependencies {