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

Final PR for the metadata repo #266

Merged
merged 12 commits into from Jul 7, 2022
Expand Up @@ -75,5 +75,6 @@ public interface SharedConstants {
String AGENT_SESSION_SUBDIR = "session-{pid}-{datetime}";
String AGENT_OUTPUT_DIRECTORY_MARKER = "{output_dir}";
String AGENT_OUTPUT_DIRECTORY_OPTION = "config-output-dir=";
String METADATA_REPO_URL_TEMPLATE = "https://github.com/graalvm/graalvm-reachability-metadata/releases/download/%1$s/graalvm-reachability-metadata-%1$s.zip";
String METADATA_REPO_URL_TEMPLATE = "https://github.com/oracle/graalvm-reachability-metadata/releases/download/%1$s/graalvm-reachability-metadata-%1$s.zip";
String METADATA_REPO_DEFAULT_VERSION = "0.1.0";
}
35 changes: 2 additions & 33 deletions docs/src/docs/asciidoc/gradle-plugin.adoc
Expand Up @@ -228,37 +228,6 @@ Currently, this feature requires the execution of the tests in the classic "JVM"

NOTE: This plugin requires JUnit Platform 1.8 or higher.

[[mockito-bytebuddy-support]]
=== Mockito / Byte Buddy support

Mockito is supported starting from version 4.5.0 (ByteBuddy >= 1.12.9) with GraalVM >= 22.1.
However, you need to add the following configuration to make it work with GraalVM 22.1:

.Enabling Mockito / Byte Buddy support on GraalVM 22.1
[source,groovy,role="multi-language-sample"]
----
graalvmNative {
binaries {
test {
buildArgs.add("--rerun-class-initialization-at-runtime=net.bytebuddy.ClassFileVersion,net.bytebuddy.utility.dispatcher.JavaDispatcher,net.bytebuddy.utility.Invoker$Dispatcher")
buildArgs.add("--initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable,net.bytebuddy.description.type.TypeDescription$AbstractBase,net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2,net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2")
}
}
}
----

[source,kotlin,role="multi-language-sample"]
----
graalvmNative {
binaries {
named("test") {
buildArgs.add("--rerun-class-initialization-at-runtime=net.bytebuddy.ClassFileVersion,net.bytebuddy.utility.dispatcher.JavaDispatcher,net.bytebuddy.utility.Invoker$Dispatcher")
buildArgs.add("--initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable,net.bytebuddy.description.type.TypeDescription$AbstractBase,net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2,net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2")
}
}
}
----

[[testing-support-disabling]]
=== Disabling testing support

Expand Down Expand Up @@ -358,8 +327,8 @@ See <<configuration-options>> for the full list of available options.
[[metadata-support]]
== GraalVM Reachability Metadata Support

Since release 0.9.11, the plugin adds experimental support for the https://github.com/graalvm/graalvm-reachability-metadata/[GraalVM reachability metadata repository].
This repository provides GraalVM configuration for libraries which do not officially support GraalVM native.
Since release 0.9.11, the plugin adds experimental support for the https://github.com/oracle/graalvm-reachability-metadata/[GraalVM reachability metadata repository].
This repository provides https://www.graalvm.org/22.2/reference-manual/native-image/ReachabilityMetadata/[reachability metadata] for libraries that do not support GraalVM Native Image.

=== Enabling the metadata repository

Expand Down
30 changes: 4 additions & 26 deletions docs/src/docs/asciidoc/maven-plugin.adoc
Expand Up @@ -349,23 +349,6 @@ with an error similar to the following when attempting to run tests in a native
[ERROR] Test configuration file wasn't found. Make sure that test execution wasn't skipped.
----

[[mockito-bytebuddy-support]]
=== Mockito / Byte Buddy support

Mockito is supported starting from version 4.5.0 (ByteBuddy >= 1.12.9) with GraalVM >= 22.1.
However, you need to add the following configuration to make it work with GraalVM 22.1:

.Enabling Mockito / Byte Buddy support on GraalVM 22.1
[source,xml]
----
<configuration>
<buildArgs>
<arg>--rerun-class-initialization-at-runtime=net.bytebuddy.ClassFileVersion,net.bytebuddy.utility.dispatcher.JavaDispatcher,net.bytebuddy.utility.Invoker$Dispatcher</arg>
<arg>--initialize-at-build-time=net.bytebuddy.description.method.MethodDescription$InDefinedShape$AbstractBase$ForLoadedExecutable,net.bytebuddy.description.type.TypeDescription$AbstractBase,net.bytebuddy.description.type.TypeDescription$ForLoadedType,net.bytebuddy.description.method.MethodDescription$ForLoadedMethod,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$1,net.bytebuddy.implementation.bind.annotation.Argument$BindingMechanic$2,net.bytebuddy.implementation.bind.annotation.Super$Instantiation$2 </arg>
</buildArgs>
</configuration>
----

[[testing-support-disabling]]
=== Disabling testing support

Expand Down Expand Up @@ -609,25 +592,20 @@ with those configuration files, you then need to execute the following command:
mvn -Pnative -Dagent=true -DskipTests package exec:exec@native
```

WARNING: If the agent is enabled, the `--allow-incomplete-classpath` option is
automatically added to your native build options.

[[metadata-support]]
== GraalVM Reachability Metadata Support

Since release 0.9.12, the plugin adds experimental support for the https://github.com/graalvm/graalvm-reachability-metadata/[GraalVM reachability metadata repository].
This repository provides GraalVM metadata for libraries which do not officially support GraalVM native.

A metadata repository consists of configuration files for GraalVM.
Since release 0.9.12, the plugin adds experimental support for the https://github.com/oracle/graalvm-reachability-metadata/[GraalVM reachability metadata repository].
This repository provides https://www.graalvm.org/22.2/reference-manual/native-image/ReachabilityMetadata/[reachability metadata] for libraries that do not support GraalVM Native Image.

=== Enabling the metadata repository

Support needs to be enabled explicitly:. It is possible to use a _local repository_, in which case you can specify the path to the repository:
Support needs to be enabled explicitly:

.Enabling the metadata repository
[source,xml,indent=0]
----
include::../../../../samples/native-config-integration/pom.xml[tag=metadata-local]
include::../../../../samples/native-config-integration/pom.xml[tag=metadata-default]
----
<1> The local path can point to an _exploded_ directory, or to a compressed ZIP file.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to remove this callout, and add the asciidoctor tags to samples/metadata-repo-integration/pom.xml.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/snippets/gradle/groovy/build.gradle
Expand Up @@ -176,7 +176,7 @@ graalvmNative {
// tag::specify-metadata-repository-version[]
graalvmNative {
metadataRepository {
version = "1.0.0"
version = "0.1.0"
}
}
// end::specify-metadata-repository-version[]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/docs/snippets/gradle/kotlin/build.gradle.kts
Expand Up @@ -189,7 +189,7 @@ graalvmNative {
// tag::specify-metadata-repository-version[]
graalvmNative {
metadataRepository {
version.set("1.0.0")
version.set("0.1.0")
}
}
// end::specify-metadata-repository-version[]
Expand Down
Expand Up @@ -423,6 +423,7 @@ private GraalVMExtension registerGraalVMExtension(Project project) {
private void configureNativeConfigurationRepo(ExtensionAware graalvmNative) {
GraalVMReachabilityMetadataRepositoryExtension configurationRepository = graalvmNative.getExtensions().create("metadataRepository", GraalVMReachabilityMetadataRepositoryExtension.class);
configurationRepository.getEnabled().convention(false);
configurationRepository.getVersion().convention(SharedConstants.METADATA_REPO_DEFAULT_VERSION);
configurationRepository.getUri().convention(configurationRepository.getVersion().map(v -> {
try {
return new URI(String.format(METADATA_REPO_URL_TEMPLATE, v));
Expand Down
Expand Up @@ -73,7 +73,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataLocal', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataDefault', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -91,7 +91,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataLocal,excludeConfigTest', '-DnativeDryRun', 'package'
mvn '-Pnative,metadataDefault,excludeConfigTest', '-DnativeDryRun', 'package'

then:
buildSucceeded
Expand Down
Expand Up @@ -44,6 +44,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugins.annotations.Parameter;
import org.graalvm.buildtools.utils.SharedConstants;

import java.io.File;
import java.net.URL;
Expand All @@ -56,7 +57,7 @@ public class MetadataRepositoryConfiguration {
@Parameter(defaultValue = "false")
private boolean enabled;

@Parameter
@Parameter(defaultValue = SharedConstants.METADATA_REPO_DEFAULT_VERSION)
private String version;

@Parameter
Expand Down
4 changes: 0 additions & 4 deletions samples/native-config-integration/build.gradle
Expand Up @@ -70,10 +70,6 @@ tasks.withType(Test).configureEach {
graalvmNative {
metadataRepository {
enabled = true
def extension = System.getProperty("extension", '')
def repo = file("config-directory${extension ? '.' + extension : ''}")
println("Using config repo: $repo")
uri(repo)
}
binaries.all {
verbose = true
Expand Down
7 changes: 3 additions & 4 deletions samples/native-config-integration/pom.xml
Expand Up @@ -148,22 +148,21 @@
</build>
</profile>
<profile>
<id>metadataLocal</id>
<id>metadataDefault</id>
alvarosanchez marked this conversation as resolved.
Show resolved Hide resolved
<build>
<plugins>
<!-- tag::metadata-local[] -->
<!-- tag::metadata-default[] -->
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native.maven.plugin.version}</version>
<configuration>
<metadataRepository>
<enabled>true</enabled>
<localPath>${project.basedir}/config-directory</localPath> <!--1-->
</metadataRepository>
</configuration>
</plugin>
<!-- end::metadata-local[] -->
<!-- end::metadata-default[] -->
</plugins>
</build>
</profile>
Expand Down