Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

docs(sample): adding native-image-sample for java-trace #732

Merged
merged 6 commits into from
Mar 2, 2022

Conversation

suztomo
Copy link
Member

@suztomo suztomo commented Mar 1, 2022

Importing google-cloud-trace's sample to this repository. I confirmed it works as samples/native-image-sample/README.md.

@suztomo suztomo requested a review from a team as a code owner March 1, 2022 21:31
@generated-files-bot
Copy link

Warning: This pull request is touching the following templated files:

  • samples/pom.xml
@product-auto-label product-auto-label bot added api: cloudtrace Issues related to the googleapis/java-trace API. samples Issues that are directly related to samples. labels Mar 1, 2022
@suztomo suztomo changed the title docs(sample): adding native-image-sample Mar 1, 2022
@suztomo suztomo requested review from mpeddada1 and Neenu1995 March 2, 2022 14:05
@suztomo suztomo assigned mpeddada1 and unassigned stephaniewang526 Mar 2, 2022
@suztomo suztomo added the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2022
Copy link
Contributor

@mpeddada1 mpeddada1 left a 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).
Copy link
Contributor

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

Copy link
Member Author

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>
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Thanks for checking.

<buildArg>--no-fallback</buildArg>
<buildArg>--no-server</buildArg>
<buildArg>--initialize-at-build-time</buildArg>
<buildArg>--features=com.google.cloud.nativeimage.features.ProtobufMessageFeature</buildArg>
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the argument.

@suztomo
Copy link
Member Author

suztomo commented Mar 2, 2022

@mpeddada1 PTAL

@suztomo suztomo added automerge Merge the pull request once unit tests and other checks pass. owlbot:run Add this label to trigger the Owlbot post processor. labels Mar 2, 2022
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Mar 2, 2022
@gcf-merge-on-green gcf-merge-on-green bot merged commit 88695dc into googleapis:main Mar 2, 2022
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Mar 2, 2022
gcf-merge-on-green bot pushed a commit that referenced this pull request Mar 3, 2022
🤖 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).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: cloudtrace Issues related to the googleapis/java-trace API. samples Issues that are directly related to samples.
3 participants