Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Intellij, why must I clean and build the war to see changes when I run Google App Engine locally?

I'm using google app engine to build a war and I've noticed that whenever I make local changes, they never get applied when I run locally. I've figured out that the only way to see the changes I've made is to run a mvn clean, then make, then build the artifact, then deploy. Here's a screenshot showing my configuration:

configuration

If I'm missing any of these steps, restarting the server doesn't show any of the changes I've made. I've made many non-google app engine webapps with intellij before and I don't normally have to do this. How can I avoid all these steps? They greatly increase the time it takes to restart my server.

In case it helps, here's my pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>

    <groupId>com.myapp</groupId>
    <artifactId>myapp</artifactId>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <appengine.target.version>1.8.6</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.stripes</groupId>
            <artifactId>stripes</artifactId>
            <version>1.5.7</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <version>1.7.5</version>
        </dependency>




        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <!-- in order to interpolate version from pom into appengine-web.xml -->
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                        <resource>
                            <directory>${basedir}/src/main/generated</directory>
                            <targetPath>src/main/generated</targetPath>
                        </resource>
                        <resource>
                            <directory>${basedir}/src/main/scripts/img</directory>
                            <targetPath>src/main/scripts/img</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
            </plugin>
        </plugins>
    </build>

</project>
like image 621
Daniel Kaplan Avatar asked Nov 06 '13 19:11

Daniel Kaplan


People also ask

How do you do clean and build in IntelliJ?

To clean up the local working copy, do one of the following: Select the desired file or directory in the Project tool window and choose Subversion | Cleanup from the context menu of the selection. Open the desired file in the editor and choose VCS | Subversion | Cleanup from the main menu.

How do I run a program locally in IntelliJ?

From the main menu, select Run | Edit Configurations. and select the configuration type that corresponds to the application server that you will use. Use a Local application server run configuration if you want it to start the server locally before deploying the artifacts.


1 Answers

If you're using .war artefact, yes, you have to clean and make because it is literally creating the war file and then deploy and in order to update the code within the war file, IntelliJ has to recreate the entire war file which is done by clean (delete) and make it again.

You should consider using .war exploded artefact so that IntelliJ can update the classes/jar files needed without the need to recreate the entire war file. However I see in your screenshot that you're already using war exploded artefact, perhaps the problem is that you're trying to update the jar file being used.

like image 64
Wins Avatar answered Sep 28 '22 21:09

Wins