Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate native configuration repository with Gradle #204

Merged
merged 8 commits into from
Mar 18, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 3 additions & 13 deletions .github/workflows/junit-platform-native-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRAALVM_HOME=$GRAALVM_HOME" >> $GITHUB_ENV
- name: Checkstyle
run: |
pushd common/junit-platform-native
./gradlew checkstyleMain
./gradlew checkstyleTest
popd
run: ./gradlew :junit-platform-native:checkstyleMain :junit-platform-native:checkstyleTest
- name: JVM test
run: |
pushd common/junit-platform-native
./gradlew test
popd
run: ./gradlew :junit-platform-native:test
- name: Feature test
run: |
pushd common/junit-platform-native
./gradlew nativeTest
popd
run: ./gradlew :junit-platform-native:nativeTest
- name: Tests results
if: always()
uses: actions/upload-artifact@v2
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/jvm-metadata-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: JVM Reachability Metadata Repository

on:
push:
paths:
- 'common/jvm-reachability-metadata/**'
pull_request:
paths:
- 'common/jvm-reachability-metadata/**'
workflow_dispatch:

jobs:
test-jvm-reachability-metadata:
name:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Get GraalVM Nightly
run: |
source common/scripts/downloadGraalVM.sh
echo "$GRAALVM_HOME/bin" >> $GITHUB_PATH
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRAALVM_HOME=$GRAALVM_HOME" >> $GITHUB_ENV
- name: Checkstyle
run: ./gradlew :jvm-reachability-metadata:checkstyleMain :jvm-reachability-metadata:checkstyleTest
- name: JVM test
run: ./gradlew :jvm-reachability-metadata:test
- name: Tests results
if: always()
uses: actions/upload-artifact@v2
with:
name: tests-results
path: common/jvm-reachability-metadata/build/reports/tests/
10 changes: 2 additions & 8 deletions .github/workflows/native-gradle-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRAALVM_HOME=$GRAALVM_HOME" >> $GITHUB_ENV
- name: Unit tests and inspections
run: |
pushd native-gradle-plugin
./gradlew test inspections
popd
run: ./gradlew :native-gradle-plugin:test :native-gradle-plugin:inspections
- name: Unit tests results
uses: actions/upload-artifact@v1
with:
Expand All @@ -57,10 +54,7 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRAALVM_HOME=$GRAALVM_HOME" >> $GITHUB_ENV
- name: Check and test the plugin
run: |
pushd native-gradle-plugin
./gradlew functionalTest -DgradleVersion=${{ matrix.gradle-version }}
popd
run: ./gradlew :native-gradle-plugin:functionalTest -DgradleVersion=${{ matrix.gradle-version }}
- name: Functional tests results
if: always()
uses: actions/upload-artifact@v2
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/native-maven-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ jobs:
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "GRAALVM_HOME=$GRAALVM_HOME" >> $GITHUB_ENV
- name: Check and test the plugin
run: |
pushd native-maven-plugin
./gradlew check --no-daemon
popd
run: ./gradlew :native-maven-plugin:check --no-daemon
- name: Tests results
if: always()
uses: actions/upload-artifact@v2
Expand Down
38 changes: 38 additions & 0 deletions common/jvm-reachability-metadata/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Copyright (c) 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.
73 changes: 73 additions & 0 deletions common/jvm-reachability-metadata/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (c) 2020, 2022 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 {
checkstyle
id("org.graalvm.build.java")
id("org.graalvm.build.publishing")
}

maven {
name.set("GraalVM JVM Reachability Metadata support")
description.set("A library to help dealing with the GraaVM JVM Reachability Metadata repository")
}

dependencies {
implementation(libs.jackson.databind)
testImplementation(platform(libs.test.junit.bom))
testImplementation(libs.test.junit.jupiter.core)
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}

tasks.withType<Checkstyle>().configureEach {
setConfigFile(layout.projectDirectory.dir("../../config/checkstyle.xml").asFile)
}
147 changes: 147 additions & 0 deletions common/jvm-reachability-metadata/gradle/native-image-testing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* Copyright (c) 2020, 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.
*/

import org.gradle.util.GFileUtils

def agentOutput = layout.buildDirectory.dir("agent")

ext {
testIdsDir = layout.buildDirectory.dir("test_ids")
}

tasks.register("testConsoleLauncher", JavaExec) {
outputs.dir(agentOutput)
classpath = test.classpath
main = "org.junit.platform.console.ConsoleLauncher"
args = ["--scan-class-path"]
doFirst {
def agentOutputDir = agentOutput.get().asFile
if (agentOutputDir.exists()) {
GFileUtils.deleteDirectory(agentOutputDir)
}
if (project.hasProperty("agent")) {
mkdir "${agentOutputDir}"
new File("${agentOutputDir}", "agent-filter.json").text = """
{
"rules":[
{
"excludeClasses":"org.gradle.**"
},
{
"excludeClasses":"java.**"
}
]
}
"""
jvmArgs = [
"-agentlib:native-image-agent=access-filter-file=${agentOutputDir}/agent-filter.json,experimental-class-loader-support,config-output-dir=${agentOutputDir}/agentOutput",
"-Dorg.graalvm.nativeimage.imagecode=agent"
]
}
}
}

abstract class NativeTestArgumentProvider implements CommandLineArgumentProvider {
@InputFiles
abstract ConfigurableFileCollection getClasspath()

@InputDirectory
abstract DirectoryProperty getTestIdsDir()

@InputDirectory
@Optional
abstract DirectoryProperty getAgentOutputDir()

@Input
abstract Property<Boolean> getDiscovery()

@Override
Iterable<String> asArguments() {
def args = [
"-cp", classpath.asPath,
"--no-fallback",
"--features=org.graalvm.junit.platform.JUnitPlatformFeature",
"-H:Name=native-image-tests",
"-H:Class=org.graalvm.junit.platform.NativeImageJUnitLauncher",
"-Djunit.platform.listeners.uid.tracking.output.dir=${testIdsDir.get().asFile.absolutePath}"
]
if (agentOutputDir.isPresent()) {
def outputDir = agentOutputDir.get().asFile
if (!outputDir.exists()) {
throw new GradleException("Agent output missing when -Pagent is set.\n" +
"You need to run `gradle -Pagent test` first.")
}

args << "-H:ConfigurationFileDirectories=${outputDir.absolutePath}/agentOutput"
args << "-H:+AllowIncompleteClasspath"
}

if (discovery.get()) {
args << "-DtestDiscovery"
}
args.collect { it.toString() }
}
}

tasks.named("test") {
doFirst {
agentOutput.get().asFile.mkdirs()
}
}

tasks.register("nativeTestCompile", Exec) {
dependsOn(test)
inputs.files(test.classpath)
workingDir "${buildDir}"
executable = System.getenv("GRAALVM_HOME") + "/bin/native-image"
def argsProvider = objects.newInstance(NativeTestArgumentProvider)
argsProvider.classpath.from(test.classpath)
argsProvider.testIdsDir.set(testIdsDir)
argsProvider.agentOutputDir.set(agentOutput)
argsProvider.discovery.set(providers.systemProperty("testDiscovery").forUseAtConfigurationTime().map(v -> Boolean.valueOf(v)).orElse(false))
argumentProviders.add(argsProvider)
}

tasks.register("nativeTest", Exec) {
dependsOn nativeTestCompile
workingDir = "${buildDir}"
executable = "${buildDir}/native-image-tests"
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists