Skip to content

Commit d695c27

Browse files
authored
Update Firestore Quickstart to use exec:exec (GoogleCloudPlatform#1523)
When exec-maven-plugin runs the `exec:java` goal, it executes the java program in the maven process (there currently isn't an option to fork instead of running it in process). As a side effect of this, shutdown hooks are not run when the program has completed running. In the case of our Quickstart that means the daemon thread for grpc and gax do not shutdown when the program has completed running, resulting in maven listing all the threads that are still running and showing a stacktrace. This change uses `exec:exec` and manually builds the java command to be run, thereby forcing the program to be ran in a forked process and able to use the normal shutdown process.
1 parent 5a37880 commit d695c27

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

firestore/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Build your project:
3535
demonstrates adding and querying documents in a collection in Firestore.
3636
You can run the quickstart with:
3737

38-
mvn exec:java -Dexec.mainClass=com.example.firestore.Quickstart -Dexec.args="your-firestore-project-id"
38+
mvn exec:exec -Dfirestore.project.id="your-firestore-project-id"
3939

4040
Note: the default project-id will be used if no argument is provided.
4141

firestore/pom.xml

+29
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<properties>
3838
<maven.compiler.target>1.8</maven.compiler.target>
3939
<maven.compiler.source>1.8</maven.compiler.source>
40+
<!-- Define a default empty value property which can be overridden on the command line if
41+
necessary by passing `-Dfirestore.project.id="some-id"` when running maven exec -->
42+
<firestore.project.id/>
4043
</properties>
4144

4245
<dependencies>
@@ -57,4 +60,30 @@
5760
<scope>test</scope>
5861
</dependency>
5962
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.codehaus.mojo</groupId>
68+
<artifactId>exec-maven-plugin</artifactId>
69+
<version>1.6.0</version>
70+
<executions>
71+
<execution>
72+
<goals>
73+
<goal>exec</goal>
74+
</goals>
75+
</execution>
76+
</executions>
77+
<configuration>
78+
<executable>java</executable>
79+
<arguments>
80+
<argument>-classpath</argument>
81+
<classpath/>
82+
<argument>com.example.firestore.Quickstart</argument>
83+
<argument>${firestore.project.id}</argument>
84+
</arguments>
85+
</configuration>
86+
</plugin>
87+
</plugins>
88+
</build>
6089
</project>

0 commit comments

Comments
 (0)