Unverified Commit 3a3d1210 authored by Luca Palmieri's avatar Luca Palmieri Committed by GitHub
Browse files

Refactor build scripts (#2116)

* Introduce a flag in gradle.properties to enable/disable testing (and the compilation of the associated dependencies).

* Feature flag testing in all non-test-only build.gradle.kts files.

* Remove dokka
parent 3e6adcd4
Loading
Loading
Loading
Loading
+34 −27
Original line number Diff line number Diff line
@@ -19,18 +19,14 @@ group = "software.amazon.software.amazon.smithy.rust.codegen.smithy"
version = "0.1.0"

val smithyVersion: String by project
val kotestVersion: String by project

dependencies {
    implementation(project(":codegen-core"))
    implementation(project(":codegen-client"))
    runtimeOnly(project(":aws:rust-runtime"))
    implementation("org.jsoup:jsoup:1.14.3")
    implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-rules-engine:$smithyVersion")
    testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
}

val generateAwsRuntimeCrateVersion by tasks.registering {
@@ -52,10 +48,6 @@ tasks.compileKotlin {
    dependsOn(generateAwsRuntimeCrateVersion)
}

tasks.compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

// Reusable license copySpec
val licenseSpec = copySpec {
    from("${project.rootDir}/LICENSE")
@@ -78,6 +70,20 @@ val sourcesJar by tasks.creating(Jar::class) {
    from(sourceSets.getByName("main").allSource)
}

val isTestingEnabled: String by project
if (isTestingEnabled.toBoolean()) {
    val kotestVersion: String by project

    dependencies {
        runtimeOnly(project(":aws:rust-runtime"))
        testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
        testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
    }

    tasks.compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }

    tasks.test {
        useJUnitPlatform()
        testLogging {
@@ -101,6 +107,7 @@ tasks.jacocoTestReport {

    // Always run the jacoco test report after testing.
    tasks["test"].finalizedBy(tasks["jacocoTestReport"])
}

publishing {
    publications {
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ buildscript {

plugins {
    kotlin("jvm") version "1.3.72" apply false
    id("org.jetbrains.dokka") version "1.7.10"
}

allprojects {
+32 −33
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat

plugins {
    kotlin("jvm")
    id("org.jetbrains.dokka")
    jacoco
    `maven-publish`
}
@@ -20,7 +19,6 @@ group = "software.amazon.smithy.rust.codegen"
version = "0.1.0"

val smithyVersion: String by project
val kotestVersion: String by project

dependencies {
    implementation(project(":codegen-core"))
@@ -30,13 +28,6 @@ dependencies {
    implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-waiters:$smithyVersion")
    implementation("software.amazon.smithy:smithy-rules-engine:$smithyVersion")
    runtimeOnly(project(":rust-runtime"))
    testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
}

tasks.compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

tasks.compileKotlin {
@@ -65,6 +56,20 @@ val sourcesJar by tasks.creating(Jar::class) {
    from(sourceSets.getByName("main").allSource)
}

val isTestingEnabled: String by project
if (isTestingEnabled.toBoolean()) {
    val kotestVersion: String by project

    dependencies {
        runtimeOnly(project(":rust-runtime"))
        testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
        testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
    }

    tasks.compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }

    tasks.test {
        useJUnitPlatform()
        testLogging {
@@ -77,13 +82,6 @@ tasks.test {
        }
    }

tasks.dokkaHtml.configure {
    outputDirectory.set(buildDir.resolve("javadoc"))
}

// Always build documentation
tasks["build"].finalizedBy(tasks["dokkaHtml"])

    // Configure jacoco (code coverage) to generate an HTML report
    tasks.jacocoTestReport {
        reports {
@@ -95,6 +93,7 @@ tasks.jacocoTestReport {

    // Always run the jacoco test report after testing.
    tasks["test"].finalizedBy(tasks["jacocoTestReport"])
}

publishing {
    publications {
+32 −33
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ import java.io.ByteArrayOutputStream

plugins {
    kotlin("jvm")
    id("org.jetbrains.dokka")
    jacoco
    `maven-publish`
}
@@ -21,7 +20,6 @@ group = "software.amazon.smithy.rust.codegen"
version = "0.1.0"

val smithyVersion: String by project
val kotestVersion: String by project

dependencies {
    implementation(kotlin("stdlib-jdk8"))
@@ -31,9 +29,6 @@ dependencies {
    implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-waiters:$smithyVersion")
    runtimeOnly(project(":rust-runtime"))
    testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
}

fun gitCommitHash(): String {
@@ -78,10 +73,6 @@ tasks.compileKotlin {
    dependsOn(generateSmithyRuntimeCrateVersion)
}

tasks.compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

// Reusable license copySpec
val licenseSpec = copySpec {
    from("${project.rootDir}/LICENSE")
@@ -104,6 +95,20 @@ val sourcesJar by tasks.creating(Jar::class) {
    from(sourceSets.getByName("main").allSource)
}

val isTestingEnabled: String by project
if (isTestingEnabled.toBoolean()) {
    val kotestVersion: String by project

    dependencies {
        runtimeOnly(project(":rust-runtime"))
        testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
        testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
    }

    tasks.compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
    }

    tasks.test {
        useJUnitPlatform()
        testLogging {
@@ -116,13 +121,6 @@ tasks.test {
        }
    }

tasks.dokkaHtml.configure {
    outputDirectory.set(buildDir.resolve("javadoc"))
}

// Always build documentation
tasks["build"].finalizedBy(tasks["dokkaHtml"])

    // Configure jacoco (code coverage) to generate an HTML report
    tasks.jacocoTestReport {
        reports {
@@ -134,6 +132,7 @@ tasks.jacocoTestReport {

    // Always run the jacoco test report after testing.
    tasks["test"].finalizedBy(tasks["jacocoTestReport"])
}

publishing {
    publications {
+21 −13
Original line number Diff line number Diff line
@@ -21,19 +21,15 @@ group = "software.amazon.smithy.rust.codegen.server.smithy"
version = "0.1.0"

val smithyVersion: String by project
val kotestVersion: String by project

dependencies {
    implementation(project(":codegen-core"))
    implementation(project(":codegen-client"))
    implementation("software.amazon.smithy:smithy-aws-traits:$smithyVersion")
    implementation("software.amazon.smithy:smithy-protocol-test-traits:$smithyVersion")
    testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
}

tasks.compileKotlin { kotlinOptions.jvmTarget = "1.8" }
tasks.compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }

// Reusable license copySpec
val licenseSpec = copySpec {
@@ -55,6 +51,17 @@ val sourcesJar by tasks.creating(Jar::class) {
    from(sourceSets.getByName("main").allSource)
}

val isTestingEnabled: String by project
if (isTestingEnabled.toBoolean()) {
    val kotestVersion: String by project

    dependencies {
        testImplementation("org.junit.jupiter:junit-jupiter:5.6.1")
        testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
    }

    tasks.compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }

    tasks.test {
        useJUnitPlatform()
        testLogging {
@@ -66,6 +73,7 @@ tasks.test {
            showStandardStreams = true
        }
    }
}

publishing {
    publications {
Loading