Skip to content

Commit b8d6110

Browse files
lesvdpebot
authored andcommitted
add war plugin (GoogleCloudPlatform#452)
1 parent 4a697a9 commit b8d6110

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

appengine/cloudsql/README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ Developers Console](https://console.developers.google.com/sql/instances). Altern
1313

1414
## Deploying
1515

16-
`$ mvn clean appengine:deploy -DINSTANCE_CONNECTION_NAME="instanceConnectionName" -Duser=root
17-
-Dpassword=myPassword -Ddatabase=myDatabase`
16+
```bash
17+
$ mvn clean appengine:deploy -DINSTANCE_CONNECTION_NAME="instanceConnectionName" -Duser=root
18+
-Dpassword=myPassword -Ddatabase=myDatabase
19+
```
1820

1921
Or you can update the properties in `pom.xml` and
2022

2123
## Running locally
2224
1. You will need to be running a local instance of MySQL.
2325

24-
`$ mvn clean appengine:run -Duser=root -Dpassword=myPassowrd -Ddatabase=myDatabase`
26+
```bash
27+
$ mvn clean appengine:run -Duser=root -Dpassword=myPassowrd -Ddatabase=myDatabase
28+
```
2529

appengine/cloudsql/pom.xml

+16-6
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,23 @@
7171
<build>
7272
<!-- for hot reload of the web application -->
7373
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
74-
<resources>
75-
<resource>
76-
<directory>src/webapp/WEB-INF</directory>
77-
<filtering>true</filtering>
78-
</resource>
79-
</resources>
8074
<plugins>
75+
<plugin>
76+
<groupId>org.apache.maven.plugins</groupId>
77+
<artifactId>maven-war-plugin</artifactId>
78+
<version>3.0.0</version>
79+
<configuration>
80+
<webResources>
81+
<!-- in order to interpolate version from pom into appengine-web.xml -->
82+
<resource>
83+
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
84+
<filtering>true</filtering>
85+
<targetPath>WEB-INF</targetPath>
86+
</resource>
87+
</webResources>
88+
</configuration>
89+
</plugin>
90+
8191
<plugin>
8292
<groupId>com.google.cloud.tools</groupId>
8393
<artifactId>appengine-maven-plugin</artifactId>

appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
8181
// Set the url with the local MySQL database connection url when running locally
8282
url = System.getProperty("ae-cloudsql.local-database-url");
8383
}
84+
log("connecting to: " + url);
8485
try (Connection conn = DriverManager.getConnection(url);
8586
PreparedStatement statementCreateVisit = conn.prepareStatement(createVisitSql)) {
8687
conn.createStatement().executeUpdate(createTableSql);

0 commit comments

Comments
 (0)