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

Fix Native configuration not applied on modules #146

Merged
merged 1 commit into from
Oct 22, 2021
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
25 changes: 18 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,26 @@ tasks.register<Zip>("releaseZip") {
}
}

tasks.register<org.graalvm.build.samples.SamplesUpdateTask>("updateSamples") {
inputDirectory.set(layout.projectDirectory.dir("samples"))
versions.put("native.gradle.plugin.version", libs.versions.nativeBuildTools.get())
versions.put("native.maven.plugin.version", libs.versions.nativeBuildTools.get())
versions.put("junit.jupiter.version", libs.versions.junitJupiter.get())
versions.put("junit.platform.version", libs.versions.junitPlatform.get())
versions.put("junit.platform.native.version", libs.versions.nativeBuildTools.get())
val updateSamples by tasks.registering

mapOf(
"updateSamplesDir" to "samples",
"updateMavenReprosDir" to "native-maven-plugin/reproducers"
).forEach { taskName, dir ->
val t = tasks.register<org.graalvm.build.samples.SamplesUpdateTask>(taskName) {
inputDirectory.set(layout.projectDirectory.dir(dir))
versions.put("native.gradle.plugin.version", libs.versions.nativeBuildTools.get())
versions.put("native.maven.plugin.version", libs.versions.nativeBuildTools.get())
versions.put("junit.jupiter.version", libs.versions.junitJupiter.get())
versions.put("junit.platform.version", libs.versions.junitPlatform.get())
versions.put("junit.platform.native.version", libs.versions.nativeBuildTools.get())
}
updateSamples.configure {
dependsOn(t)
}
}


val cloneSnapshots = tasks.register<org.graalvm.build.tasks.GitClone>("cloneSnapshotRepository") {
repositoryUri.set("git@github.com:graalvm/native-build-tools.git")
// repositoryUri.set(file(".").absolutePath)
Expand Down
6 changes: 6 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ If you are interested in contributing, please refer to our https://github.com/gr
[[changelog]]
== Changelog

=== Release 0.9.7

==== Bugfixes

- Fixed https://github.com/graalvm/native-build-tools/issues/144[Maven plugin configuration not applied if declared in a parent POM].

=== Release 0.9.6

==== Upgrade to JUnit 5.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ configurations {
tasks.register<Test>("functionalTest") {
// Any change to samples invalidates functional tests
inputs.files(files("../samples"))
inputs.files(files("reproducers"))
inputs.files(functionalTestCommonRepository)
systemProperty("common.repo.url", functionalTestCommonRepository.incoming.files.files.first())
testClassesDirs = functionalTest.output.classesDirs
Expand Down
55 changes: 55 additions & 0 deletions native-maven-plugin/reproducers/issue-144/child/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.graalvm.buildtools.examples</groupId>
<artifactId>maven</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>child</artifactId>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.graalvm.demo;

public class Application {
static String getMessage() {
return "Hello, native!";
}

public static void main(String[] args) {
System.out.println(getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.graalvm.demo;

public class Calculator {

public int add(int a, int b) {
return a + b;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.graalvm.demo;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class CalculatorTest {

@Test
@DisplayName("1 + 1 = 2")
void addsTwoNumbers() {
Calculator calculator = new Calculator();
assertEquals(2, calculator.add(1, 1), "1 + 1 should equal 2");
}

@Test
@DisplayName("1 + 2 = 3")
void addsTwoNumbers2() {
Calculator calculator = new Calculator();
assertEquals(3, calculator.add(1, 2), "1 + 2 should equal 3");
}

@ParameterizedTest(name = "{0} + {1} = {2}")
@CsvSource({
"0, 1, 1",
"1, 2, 3",
"49, 51, 100",
"1, 100, 101"
})
void add(int first, int second, int expectedResult) {
Calculator calculator = new Calculator();
assertEquals(expectedResult, calculator.add(first, second),
() -> first + " + " + second + " should equal " + expectedResult);
}
}
134 changes: 134 additions & 0 deletions native-maven-plugin/reproducers/issue-144/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.graalvm.buildtools.examples</groupId>
<artifactId>maven</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>child</module>
</modules>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<native.maven.plugin.version>0.9.7-SNAPSHOT</native.maven.plugin.version>
<junit.platform.native.version>0.9.7-SNAPSHOT</junit.platform.native.version>
<imageName>example-app</imageName>
<mainClass>org.graalvm.demo.Application</mainClass>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<id>test-native</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
<execution>
<id>build-native</id>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<skip>false</skip>
<imageName>${imageName}</imageName>
<buildArgs>
<buildArg>--no-fallback</buildArg>
</buildArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>1.8</target>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.
*/

package org.graalvm.buildtools.maven.issues

import org.graalvm.buildtools.maven.AbstractGraalVMMavenFunctionalTest

class JavaAppWithTestsAndParentPomFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
def "can run tests in a native image with the Maven plugin"() {
withReproducer("issue-144")

when:
mvn '-Pnative', 'test'

then:
buildSucceeded
outputContains "[junit-platform-native] Running in 'test listener' mode"
outputContains """
[ 3 containers found ]
[ 0 containers skipped ]
[ 3 containers started ]
[ 0 containers aborted ]
[ 3 containers successful ]
[ 0 containers failed ]
[ 6 tests found ]
[ 0 tests skipped ]
[ 6 tests started ]
[ 0 tests aborted ]
[ 6 tests successful ]
[ 0 tests failed ]
""".trim()
}

}