-
Notifications
You must be signed in to change notification settings - Fork 18
docs(sample): adding native-image-sample for java-trace #732
docs(sample): adding native-image-sample for java-trace #732
Conversation
Warning: This pull request is touching the following templated files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Added a few minor comments.
|
||
## Setup Instructions | ||
|
||
1. Follow the [GCP Project and Native Image Setup Instructions](../../README.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link will disappear once we archive the repo. How about we copy over the contents? https://github.com/GoogleCloudPlatform/native-image-support-java/blob/master/native-image-samples/README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Fixed.
<mainClass>trace.TraceSampleApplication</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we modify this to:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>dependency-jars/</classpathPrefix>
<mainClass>trace.TraceSampleApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dependency-jars/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
I realized that using just the maven-jar-plugin is not enough to create a working JAR. We also need to specify a classpath with the dependency JARs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I confirmed that java -jar target/native-image-sample-0.1.0.jar
works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for checking.
samples/native-image-sample/pom.xml
Outdated
<buildArg>--no-fallback</buildArg> | ||
<buildArg>--no-server</buildArg> | ||
<buildArg>--initialize-at-build-time</buildArg> | ||
<buildArg>--features=com.google.cloud.nativeimage.features.ProtobufMessageFeature</buildArg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we remove this --features
option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just works. Should I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Yup, let's remove it. This sample doesn't need the extra protobuf configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the argument.
@mpeddada1 PTAL |
🤖 I have created a release *beep* *boop* --- ### [2.1.4](v2.1.3...v2.1.4) (2022-03-03) ### Documentation * **sample:** adding native-image-sample for java-trace ([#732](#732)) ([88695dc](88695dc)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#734](#734)) ([dfe6d94](dfe6d94)) * update dependency com.google.cloud:native-image-support to v0.12.6 ([#737](#737)) ([c27d313](c27d313)) * update dependency org.graalvm.buildtools:junit-platform-native to v0.9.10 ([#738](#738)) ([94e1915](94e1915)) * update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.10 ([#739](#739)) ([a6598fa](a6598fa)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Importing google-cloud-trace's sample to this repository. I confirmed it works as
samples/native-image-sample/README.md
.