Skip to content

Commit 7e16977

Browse files
alvarosanchezmelix
authored andcommitted
Add functional test
1 parent 77941e4 commit 7e16977

File tree

5 files changed

+213
-0
lines changed

5 files changed

+213
-0
lines changed

native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationFunctionalTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,16 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
8282
argFile << [true, false]
8383
}
8484
85+
def "can build and execute a native image with the Maven plugin when the application has a custom packaging type"() {
86+
withSample("java-application-with-custom-packaging")
87+
88+
when:
89+
mvn 'package', '-Dpackaging=native-image', 'exec:exec@native'
90+
91+
then:
92+
buildSucceeded
93+
outputContains "ImageClasspath Entry: org.graalvm.buildtools.examples:java-application-with-custom-packaging:native-image:0.1"
94+
outputContains "Hello, native!"
95+
}
96+
8597
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
4+
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
6+
The Universal Permissive License (UPL), Version 1.0
7+
8+
Subject to the condition set forth below, permission is hereby granted to any
9+
person obtaining a copy of this software, associated documentation and/or
10+
data (collectively the "Software"), free of charge and under any and all
11+
copyright rights in the Software, and any and all patent rights owned or
12+
freely licensable by each licensor hereunder covering either (i) the
13+
unmodified Software as contributed to or provided by such licensor, or (ii)
14+
the Larger Works (as defined below), to deal in both
15+
16+
(a) the Software, and
17+
18+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
19+
one is included with the Software each a "Larger Work" to which the Software
20+
is contributed by such licensors),
21+
22+
without restriction, including without limitation the rights to copy, create
23+
derivative works of, display, perform, and distribute the Software and make,
24+
use, sell, offer for sale, import, export, have made, and have sold the
25+
Software and the Larger Work(s), and to sublicense the foregoing rights on
26+
either these or other terms.
27+
28+
This license is subject to the following condition:
29+
30+
The above copyright notice and either this complete permission notice or at a
31+
minimum a reference to the UPL must be included in all copies or substantial
32+
portions of the Software.
33+
34+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
40+
SOFTWARE.
41+
-->
42+
43+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
45+
<modelVersion>4.0.0</modelVersion>
46+
<groupId>org.graalvm.buildtools.examples</groupId>
47+
<artifactId>java-application-with-custom-packaging</artifactId>
48+
<version>0.1</version>
49+
<packaging>${packaging}</packaging>
50+
51+
<parent>
52+
<groupId>io.micronaut</groupId>
53+
<artifactId>micronaut-parent</artifactId>
54+
<version>3.3.4</version>
55+
</parent>
56+
57+
<properties>
58+
<packaging>jar</packaging>
59+
<jdk.version>11</jdk.version>
60+
<release.version>11</release.version>
61+
<micronaut.version>3.3.4</micronaut.version>
62+
<exec.mainClass>org.graalvm.demo.Application</exec.mainClass>
63+
<micronaut.runtime>netty</micronaut.runtime>
64+
<maven.native.plugin.version>0.9.11-SNAPSHOT</maven.native.plugin.version>
65+
</properties>
66+
67+
<repositories>
68+
<repository>
69+
<id>central</id>
70+
<url>https://repo.maven.apache.org/maven2</url>
71+
</repository>
72+
</repositories>
73+
74+
<dependencies>
75+
<dependency>
76+
<groupId>io.micronaut</groupId>
77+
<artifactId>micronaut-inject</artifactId>
78+
<scope>compile</scope>
79+
</dependency>
80+
<dependency>
81+
<groupId>io.micronaut</groupId>
82+
<artifactId>micronaut-validation</artifactId>
83+
<scope>compile</scope>
84+
</dependency>
85+
<dependency>
86+
<groupId>io.micronaut</groupId>
87+
<artifactId>micronaut-http-client</artifactId>
88+
<scope>test</scope>
89+
</dependency>
90+
<dependency>
91+
<groupId>org.junit.jupiter</groupId>
92+
<artifactId>junit-jupiter-api</artifactId>
93+
<scope>test</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>org.junit.jupiter</groupId>
97+
<artifactId>junit-jupiter-engine</artifactId>
98+
<scope>test</scope>
99+
</dependency>
100+
<dependency>
101+
<groupId>io.micronaut.test</groupId>
102+
<artifactId>micronaut-test-junit5</artifactId>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>info.picocli</groupId>
107+
<artifactId>picocli</artifactId>
108+
<scope>compile</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>io.micronaut</groupId>
112+
<artifactId>micronaut-jackson-databind</artifactId>
113+
<scope>compile</scope>
114+
</dependency>
115+
<dependency>
116+
<groupId>io.micronaut</groupId>
117+
<artifactId>micronaut-runtime</artifactId>
118+
<scope>compile</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>io.micronaut.picocli</groupId>
122+
<artifactId>micronaut-picocli</artifactId>
123+
<scope>compile</scope>
124+
</dependency>
125+
<dependency>
126+
<groupId>jakarta.annotation</groupId>
127+
<artifactId>jakarta.annotation-api</artifactId>
128+
<scope>compile</scope>
129+
</dependency>
130+
<dependency>
131+
<groupId>ch.qos.logback</groupId>
132+
<artifactId>logback-classic</artifactId>
133+
<scope>runtime</scope>
134+
</dependency>
135+
</dependencies>
136+
137+
<build>
138+
<plugins>
139+
<plugin>
140+
<groupId>io.micronaut.build</groupId>
141+
<artifactId>micronaut-maven-plugin</artifactId>
142+
</plugin>
143+
144+
<plugin>
145+
<groupId>org.apache.maven.plugins</groupId>
146+
<artifactId>maven-compiler-plugin</artifactId>
147+
<configuration>
148+
<!-- Uncomment to enable incremental compilation -->
149+
<!-- <useIncrementalCompilation>false</useIncrementalCompilation> -->
150+
151+
<annotationProcessorPaths combine.children="append">
152+
<path>
153+
<groupId>info.picocli</groupId>
154+
<artifactId>picocli-codegen</artifactId>
155+
<version>${picocli.version}</version>
156+
</path>
157+
</annotationProcessorPaths>
158+
<compilerArgs>
159+
<arg>-Amicronaut.processing.group=org.graalvm.demo</arg>
160+
<arg>-Amicronaut.processing.module=demo</arg>
161+
</compilerArgs>
162+
</configuration>
163+
</plugin>
164+
</plugins>
165+
</build>
166+
167+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.graalvm.demo;
2+
3+
import io.micronaut.configuration.picocli.PicocliRunner;
4+
import picocli.CommandLine.Command;
5+
6+
@Command(name = "demo", description = "...", mixinStandardHelpOptions = true)
7+
public class Application implements Runnable {
8+
9+
public static void main(String[] args) {
10+
PicocliRunner.run(Application.class, args);
11+
}
12+
13+
public void run() {
14+
System.out.println("Hello, native!");
15+
}
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
micronaut:
2+
application:
3+
name: java-application-with-custom-packaging
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<configuration>
2+
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<withJansi>true</withJansi>
5+
<!-- encoders are assigned the type
6+
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
7+
<encoder>
8+
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
9+
</encoder>
10+
</appender>
11+
12+
<root level="info">
13+
<appender-ref ref="STDOUT" />
14+
</root>
15+
</configuration>

0 commit comments

Comments
 (0)