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

Test and fix --exclude-config regression #341

Merged
merged 2 commits into from
Oct 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
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -424,8 +425,11 @@ private static URI computeMetadataRepositoryUri(Project project,
}

private void configureJvmReachabilityExcludeConfigArgs(Project project, GraalVMExtension graalExtension, NativeImageOptions options, SourceSet sourceSet) {
options.getExcludeConfig().putAll(graalVMReachabilityQuery(project, graalExtension, sourceSet,
DirectoryConfiguration::isOverride, this::getExclusionConfig,
Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
GraalVMReachabilityMetadataRepositoryExtension repositoryExtension = reachabilityExtensionOn(graalExtension);
Provider<GraalVMReachabilityMetadataService> serviceProvider = project.getGradle()
project.getGradle()
.getSharedServices()
.registerIfAbsent("nativeConfigurationService", GraalVMReachabilityMetadataService.class, spec -> {
LogLevel logLevel = determineLogLevel();
Expand All @@ -436,6 +440,12 @@ private void configureJvmReachabilityExcludeConfigArgs(Project project, GraalVME
});
}

private Map.Entry<String, List<String>> getExclusionConfig(ModuleVersionIdentifier moduleVersion,
DirectoryConfiguration configuration) {
String gav = moduleVersion.getGroup() + ":" + moduleVersion.getName() + ":" + moduleVersion.getVersion();
return new AbstractMap.SimpleEntry<>(gav, Arrays.asList("^/META-INF/native-image/.*"));
}

private static LogLevel determineLogLevel() {
LogLevel logLevel = LogLevel.DEBUG;
String loggingProperty = System.getProperty(CONFIG_REPO_LOGLEVEL);
Expand Down
9 changes: 7 additions & 2 deletions samples/metadata-repo-integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,21 @@ repositories {
}

application {
mainClass.set('org.graalvm.example.H2Example')
mainClass.set('org.graalvm.example.Example')
}

String h2_version = getProperty("h2.version")
String netty_version = getProperty("netty.version")

String logback_version = getProperty("logback.version")
String log4j_version = getProperty("log4j.version")
String slf4j_version = getProperty("slf4j.version")

dependencies {
implementation("com.h2database:h2:$h2_version")
implementation("io.netty:netty-codec-http:$netty_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("org.apache.logging.log4j:log4j-to-slf4j:$log4j_version")
implementation("org.slf4j:jul-to-slf4j:$slf4j_version")
}

graalvmNative {
Expand Down
3 changes: 3 additions & 0 deletions samples/metadata-repo-integration/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
native.gradle.plugin.version = 0.9.16-SNAPSHOT
h2.version = 2.1.210
netty.version = 4.1.80.Final
logback.version = 1.4.4
log4j.version = 2.19.0
slf4j.version = 2.0.3
31 changes: 28 additions & 3 deletions samples/metadata-repo-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@
<native.maven.plugin.version>0.9.16-SNAPSHOT</native.maven.plugin.version>
<junit.platform.native.version>0.9.16-SNAPSHOT</junit.platform.native.version>
<h2.version>2.1.210</h2.version>
<imageName>h2-demo</imageName>
<mainClass>org.graalvm.example.H2Example</mainClass>
<netty.version>4.1.80.Final</netty.version>
<logback.version>1.4.4</logback.version>
<log4j.version>2.19.0</log4j.version>
<slf4j.version>2.0.3</slf4j.version>

<imageName>metadata-repo-demo</imageName>
<mainClass>org.graalvm.example.Example</mainClass>
</properties>

<dependencies>
Expand All @@ -64,6 +69,26 @@
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -118,7 +143,7 @@
<!-- tag::metadata-versioned[] -->
<metadataRepository>
<enabled>true</enabled>
<version>0.1.0</version>
<version>0.2.3</version>
</metadataRepository>
<!-- end::metadata-versioned[] -->
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion samples/metadata-repo-integration/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pluginManagement {
}
}

rootProject.name = 'h2-demo'
rootProject.name = 'metadata-repo-demo'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.graalvm.example;

public class Example {

public static void main(String[] args) throws Exception {
H2Example.test();
NettyExample.test();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class H2Example {

public static final String JDBC_CONNECTION_URL = "jdbc:h2:./data/test";

public static void main(String[] args) throws Exception {
public static void test() throws Exception {
// Cleanup
withConnection(JDBC_CONNECTION_URL, connection -> {
connection.prepareStatement("DROP TABLE IF EXISTS customers").execute();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.graalvm.example;

import io.netty.handler.codec.http.cookie.ServerCookieDecoder;

public class NettyExample {

public static void test() {
ServerCookieDecoder.STRICT.decode("");
}

}