Skip to content

Commit ac7ad41

Browse files
author
Aleksandar Gradinac
committed
Build and run the metadata integration sample with Maven
1 parent cafbc13 commit ac7ad41

File tree

3 files changed

+227
-2
lines changed

3 files changed

+227
-2
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import org.graalvm.buildtools.gradle.fixtures.AbstractFunctionalTest
4545
import org.gradle.api.logging.LogLevel
4646
import spock.lang.Unroll
4747

48-
class RemoteMetadataRepoFunctionalTest extends AbstractFunctionalTest {
48+
class OfficialMetadataRepoFunctionalTest extends AbstractFunctionalTest {
4949

50-
def "can build and run a native-image using metadata from the remote repository"() {
50+
def "the application runs when using the official metadata repository"() {
5151
given:
5252
withSample("metadata-repo-integration")
5353

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
42+
package org.graalvm.buildtools.maven
43+
44+
class OfficialMetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
45+
void "the application runs when using the official metadata repository"() {
46+
given:
47+
withSample("metadata-repo-integration")
48+
49+
when:
50+
mvn '-Pnative', '-DskipTests', 'package', 'exec:exec@native'
51+
52+
then:
53+
buildSucceeded
54+
55+
and: "the run succeeded and retrieved data from the database"
56+
outputContains "Customers in the database"
57+
58+
and: "finds metadata in the remote repository"
59+
outputContains "[graalvm reachability metadata repository for com.h2database:h2:2.1.210]: Configuration directory is com.h2database/h2/2.1.210"
60+
}
61+
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2022, 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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
44+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
45+
<modelVersion>4.0.0</modelVersion>
46+
47+
<groupId>org.graalvm.buildtools.examples</groupId>
48+
<artifactId>maven</artifactId>
49+
<version>1.0.0-SNAPSHOT</version>
50+
51+
<properties>
52+
<java.version>1.8</java.version>
53+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
54+
<native.maven.plugin.version>0.9.13-SNAPSHOT</native.maven.plugin.version>
55+
<junit.platform.native.version>0.9.13-SNAPSHOT</junit.platform.native.version>
56+
<h2.version>2.1.210</h2.version>
57+
<imageName>h2-demo</imageName>
58+
<mainClass>org.graalvm.example.H2Example</mainClass>
59+
</properties>
60+
61+
<dependencies>
62+
<dependency>
63+
<groupId>com.h2database</groupId>
64+
<artifactId>h2</artifactId>
65+
<version>${h2.version}</version>
66+
</dependency>
67+
</dependencies>
68+
69+
<profiles>
70+
<profile>
71+
<id>native</id>
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.graalvm.buildtools</groupId>
76+
<artifactId>native-maven-plugin</artifactId>
77+
<version>${native.maven.plugin.version}</version>
78+
<extensions>true</extensions>
79+
<executions>
80+
<execution>
81+
<id>build-native</id>
82+
<goals>
83+
<goal>build</goal>
84+
</goals>
85+
<phase>package</phase>
86+
</execution>
87+
</executions>
88+
<configuration>
89+
<skip>false</skip>
90+
<imageName>${imageName}</imageName>
91+
<fallback>false</fallback>
92+
<metadataRepository>
93+
<enabled>true</enabled>
94+
</metadataRepository>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
</profile>
100+
</profiles>
101+
102+
<build>
103+
<finalName>${project.artifactId}</finalName>
104+
<plugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-surefire-plugin</artifactId>
108+
<version>3.0.0-M5</version>
109+
</plugin>
110+
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-compiler-plugin</artifactId>
114+
<version>3.8.1</version>
115+
<configuration>
116+
<source>${java.version}</source>
117+
<target>1.8</target>
118+
</configuration>
119+
</plugin>
120+
121+
<plugin>
122+
<groupId>org.apache.maven.plugins</groupId>
123+
<artifactId>maven-jar-plugin</artifactId>
124+
<version>3.2.2</version>
125+
<configuration>
126+
<archive>
127+
<manifest>
128+
<addClasspath>true</addClasspath>
129+
<mainClass>${mainClass}</mainClass>
130+
</manifest>
131+
</archive>
132+
</configuration>
133+
</plugin>
134+
135+
<plugin>
136+
<groupId>org.codehaus.mojo</groupId>
137+
<artifactId>exec-maven-plugin</artifactId>
138+
<version>3.0.0</version>
139+
<executions>
140+
<execution>
141+
<id>java</id>
142+
<goals>
143+
<goal>java</goal>
144+
</goals>
145+
<configuration>
146+
<mainClass>${mainClass}</mainClass>
147+
</configuration>
148+
</execution>
149+
<execution>
150+
<id>native</id>
151+
<goals>
152+
<goal>exec</goal>
153+
</goals>
154+
<configuration>
155+
<executable>${project.build.directory}/${imageName}</executable>
156+
<workingDirectory>${project.build.directory}</workingDirectory>
157+
</configuration>
158+
</execution>
159+
</executions>
160+
</plugin>
161+
</plugins>
162+
</build>
163+
164+
</project>

0 commit comments

Comments
 (0)