Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/junit-platform-native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'checkstyle'
id 'maven-publish'
id 'signing'
id 'org.graalvm.build.interop.publishing'
}

compileJava {
Expand Down Expand Up @@ -89,7 +90,7 @@ signing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
44 changes: 44 additions & 0 deletions common/junit-platform-native/buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2021, 2021 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugins {
id 'groovy-gradle-plugin'
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (c) 2021, 2021 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* This file configures publishing for interoperability with other
* Gradle builds. In particular, the Gradle plugin requires the JUnit
* library produced by this build, but it needs it in the form of
* a Maven repository because it's going to be consumed from integration
* tests.
*
* This means that the traditional composite build system which allows
* subsistuing a binary dependency with a source dependency isn't sufficient
* in this case.
*
*/

plugins.withId('maven-publish') {
// This is the location where we will generate a local repository
// containing the JUnit library. We DON'T use mavenLocal() because
// this repository requires manual publishing and is considered a
// bad practice because it's unreliable wrt reproducibible builds
def repoDirectory = providers.systemProperty("commonRepoPath")
.forUseAtConfigurationTime()
.orElse(layout.buildDirectory.dir("repo"))
.forUseAtConfigurationTime()

configurations {
// Configure an outgoing configuration which artifact
// is going to be the local Maven repository we generate
repositoryElements {
canBeConsumed = true
canBeResolved = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "repository"))
}
outgoing {
artifact(repoDirectory) {
builtBy { tasks.named("publishMavenJavaPublicationToCommonRepository") }
}
}
}
}

// Register a new software component which is used to "publish" the repository
// and is visible via composite builds
def softwareComponentFactory = objects.newInstance(Services).softwareComponentFactory
def adhoc = softwareComponentFactory.adhoc("commonRepository")
adhoc.addVariantsFromConfiguration(configurations.repositoryElements) {
mapToOptional()
}

publishing {
repositories {
maven {
name = "common"
url = repoDirectory
}
}
}

// This is a performance optimization: publishing is only required
// if we actually changed the artifact
tasks.matching { it.name == "publishMavenJavaPublicationToCommonRepository" }.configureEach { t ->
t.outputs.upToDateWhen {
!tasks.jar.didWork && file(repoDirectory.get()).exists()
}
}
}

// Get a handle on the software component factory
interface Services {
@javax.inject.Inject
SoftwareComponentFactory getSoftwareComponentFactory()
}
24 changes: 18 additions & 6 deletions native-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ plugins {
id 'checkstyle'
id 'maven-publish'
id 'com.gradle.plugin-publish' version '0.15.0'
id 'java-test-fixtures'
id 'org.graalvm.build.functional-testing'
}

compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
testImplementation libs.test.spock
testFixturesImplementation libs.test.spock
testFixturesImplementation gradleTestKit()
functionalTestCommonRepository(libs.junitPlatformNative)
}

pluginBundle {
website = 'https://graalvm.org/'
vcsUrl = 'https://github.com/graalvm/native-build-tools'
Expand Down Expand Up @@ -78,7 +87,10 @@ publishing {
}

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
// Use a different toolchain version from the compilation
// so that we can generate HTML5 docs
javadocTool = javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(11)
}
options.addBooleanOption('html5', true)
}
43 changes: 43 additions & 0 deletions native-gradle-plugin/buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2021, 2021 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
plugins {
id 'groovy-gradle-plugin'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2021, 2021 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* This file configures functional testing of the plugin.
*
* It will create 2 test suites that one can choose from:
*
* - a minimal test coverage suite only testing the current version of Gradle
* - a full test suite verifying the behavior will all supported versions of Gradle
*/

plugins {
id 'groovy'
}

// Add a source set for the functional test suite
sourceSets {
functionalTest
}

configurations {
// This configuration will trigger the composite build
// which builds the JUnit native library, and publish it to a repository
// which can then be injected into tests
functionalTestCommonRepository {
canBeResolved = true
canBeConsumed = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "repository"))
}
}
}

gradlePlugin.testSourceSets(sourceSets.functionalTest)
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)

['functionalTest', 'fullFunctionalTest'].each {
// Add a task to run the functional tests
tasks.register(it, Test) {
// Any change to samples invalidates functional tests
inputs.files(files("src/samples"))
inputs.files(configurations.functionalTestCommonRepository)
systemProperty('common.repo.url', configurations.functionalTestCommonRepository.incoming.files.files[0])
systemProperty('versions.junit', project.properties.junit_jupiter_version)
environment('GRAALVM_HOME', javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
vendor.set(JvmVendorSpec.matching("GraalVM Community"))
}.forUseAtConfigurationTime().get().metadata.installationPath.asFile.absolutePath)
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}
}

tasks.named('fullFunctionalTest') {
systemProperty('full.coverage', 'true')
}

tasks.named('check') {
// Run the functional tests as part of `check`
dependsOn(tasks.fullFunctionalTest)
}

tasks.withType(Test).configureEach {
useJUnitPlatform()
}
6 changes: 6 additions & 0 deletions native-gradle-plugin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[versions]
spock = "2.0-groovy-3.0"

[libraries]
junitPlatformNative = { module = "org.graalvm.buildtools:junit-platform-native", version = "" }
test-spock = { module = "org.spockframework:spock-core", version.ref = "spock" }
4 changes: 4 additions & 0 deletions native-gradle-plugin/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
*/

rootProject.name = 'native-gradle-plugin'

enableFeaturePreview("VERSION_CATALOGS")

includeBuild("../common/junit-platform-native")
Loading