appengine-maven-plugin在代码更改后不会自动部署代码

时间:2014-09-02 13:17:33

标签: maven autodeploy appengine-maven-plugin

我有一个使用新推荐的模块结构的appengine maven项目。所以我有一个耳模块,它又包含2个war子模块。我正在使用run mvn appengine:来自ear目录的devserver来运行代码。我希望maven在保存后立即部署任何代码更改,以便我可以刷新浏览器并查看更改,但这似乎不起作用。这是我的耳朵。

 目标/ $ {project.artifactId} - $ {project.version} / * / WEB-INF / classes目录                                       org.apache.maven.plugins                 行家入耳式插件                 2.8                                      五                     LIB                     战争                                                            com.google.appengine                 AppEngine上,Maven的插件                 $ {} appengine.target.version                                      2                                            

<dependencies>
    <dependency>
        <groupId>com.blah.app</groupId>
        <artifactId>A</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>com.blah.backend</groupId>
        <artifactId>B</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>
</dependencies>

按照https://developers.google.com/appengine/docs/java/tools/maven的建议,我已经在build指令下的buildOuputput目录中添加了并且还指定了

<configuration>
  <fullScanSeconds>2</fullScanSeconds>
</configuration>

在appengine-maven-plugin插件下。我还在netbeans中启用了save on save选项,但是当devappserver运行时,maven似乎没有扫描classes文件夹并部署更改。

现在,我每次小变化都会陷入干净的构建/部署周期。我真的很感激你的帮助。

1 个答案:

答案 0 :(得分:0)

我设法通过调用war在Eclipse中工作:从编译阶段爆炸并在m2e配置中添加映​​射,以便它在Eclipse中的增量构建中运行它。我不确定这在Netbeans中是如何工作的,但也许我的Eclipse解决方案可以帮助你。

以下是我的pom的相关部分:

这是配置战争的部分:爆炸执行:

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</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>
                </webResources>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>exploded</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

这是配置m2e的部分(它位于pom.xml的构建部分):

      <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-war-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.4,)
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            exploded
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute>
                                        <runOnIncremental>true</runOnIncremental>
                                        <runOnConfiguration>true</runOnConfiguration>
                                    </execute>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>