应用程序引擎+模块+ maven的开发工作流程 [英] Dev workflow for app engine + modules + maven

查看:249
本文介绍了应用程序引擎+模块+ maven的开发工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近根据以下结构将我们的应用程序引擎项目转换为模块。这个新的开发工作流程的问题在于,我们必须在每次更改时重新构建EAR并重新启动应用引擎本地开发服务器。每当我们对代码进行修改并且想要测试它时,这使得我们在30秒到一分钟之间就会松动。

  / commons 
-pom.xml
/ model
-pom.xml
/ webapp //应用程序引擎模块
-pom.xml
/ apis //应用程序引擎模块
-pom.xml
/ ear
-pom.xml
pom.xml // main(parent)project pom

在我们之前的工作流程中,单片应用程序,我们可以使用应用程序引擎的热重载功能,在IDE中修改代码(例如eclipse)将被自动获取。

在这种情况下,你们推荐什么作为最好的maven配置和/或开发工作流程?理想情况下,任何模块的更改都不需要完全重建项目。

解决方案

我正在使用类似的结构有一个小的差异。顶级目录有战争和耳朵,然后它们包含他们特定的pom.xml。我使用Eclipse进行调试,并且能够大部分时间进行热部署,而我没有使用Eclipse插件,这是我的理解。



< h2>目录结构

 
| - pom.xml
| - README.md
| - my-ear
| | - devpid
| | - pom.xml
| ` - src
| ` - 主
| ` - 申请
| ` - META-INF
` - my-war
| - build
| ` - 类
| | - 主
| | | - java
| | ` - webapp
| ` - 测试
| ` - java
| - pom.xml
` - src
| - main
| | - java
| | ` - com
| ` - webapp
| | - css
| | - favicon.ico
| | - index.html
| | - js
| | - test.html
| ` - WEB-INF
` - 测试
` - java



工具




  • 未使用Google App Engine插件(或SDK)的Eclipse Luna
  • Maven 3.2.1

  • Google App Engine SDK 1.9.6

    $ b

    开发工作流程




    1. 如果您已经有源代码,请将其保存在其他地方并使用mvn appengine命令生成一个框架。

    2. 仅使用maven和terminal以及mvn appengine:devserver命令,使用简单的Hello World运行第一次剪切。

    3. 完成后,生成eclipse项目。

    4. 将eclipse项目导入为Maven项目。它会通过Maven看到罐子。我不会在Luna之前写下这个答案,因为它需要太多的调整。在月神,这自动运作。

    5. 上面的步骤将创建三个项目,顶层,ear和war,每个项目都带有pom.xml - 没关系。

    6. 在eclipse中,将输出目录提供为war / target目录。这是可以热部署的步骤。

    7. 在maven ear / pom.xml中,将xArgs添加到appengine插件以在调试模式下运行。

       < plugin> 
      < groupId> com.google.appengine< / groupId>
      < artifactId> appengine-maven-plugin< / artifactId>
      < version> $ {appengine.target.version}< / version>
      <配置>
      < jvmFlags>
      < jvmFlag> -Xdebug< / jvmFlag>
      < jvmFlag> -Xrunjdwp:transport = dt_socket,address = 1044,server = y,suspend = n< / jvmFlag>
      < / jvmFlags>
      < disableUpdateCheck> true< / disableUpdateCheck>
      < / configuration>
      < / plugin>


    8. 注意suspend = n。


    9. 使用mvn appengine:ear目录下的devserver 从eclipse外部运行应用引擎。我使用这个命令:
      mvn appengine:devserver> 〜/ .logs / .appengine.devserver.logs& echo $! > devpid
      让我们调用这个终端1.
    10. 这个方法的一个优点是你的控制台不被Eclipse捕获,所以你可以自由使用您可以选择查看它的工具,如multitail等。我使用这个简单的tail命令:
      tail -f〜/ .logs / .appengine.devserver.logs | sed's / INFO / ^ [[0; 34m& ^ [[0m / g; s / ERROR / ^ [[0; 31m& ^ [[0m / g; s / WARN\ | WARNING / ^ [[0 ; 35m& [[0m / g; s / SEVERE \\ | FATAL / ^ [[0; 31; 47m& ^ [[0m / g'
      上面是一个困难键入命令。 ^ [的每个实例实际上是Ctrl + V Esc - 值得一次输入它的努力。但这当然是主观的,取决于你。

    11. 在Eclipse中,在远程Java应用程序下为您的项目创建一个调试配置文件 - 选择war项目和套接字附加选项。这个步骤在很多地方都可以在互联网上找到,这里有一个图像


    12. 在war目录中打开另一个终端2,并保持打开状态,以便运行 mvn compile install当你需要的时候


    13. 你很好走。您应该能够通过将其粘贴到正确的位置来整合源代码。你也应该能够使用标准的调试技术。 Eclipse会在正确的位置进行编译,devserver会检测到它。如果Eclipse抛出警告,请忽略它。

    14. 大部分时间都适用。有时候,你会保存一些破坏整个项目编译的东西,或者改变一个从预编译类中调用的函数名,或者简单地改变在启动时加载的web.xml。当然,热部署将无法工作。 在这种情况下,停止从eclipse中删除调试,完成你的任务,从终端2运行 mvn compile install 。Devserver将自动检测。

    15. 大多数情况下,我几乎不需要触摸终端1中运行的尾部.Devserver不需要重新启动。

    16. 除非我正在更改web.xml或重构,否则我不需要从外部运行 mvn compile install






    我给窗口列表(Eclipse,Terminal 1和Terminal 2)只是为了说明在eclipse中Alt + Tab实际上比Shift + F7更快。这是主观的,当然也取决于你。

    We recently converted our app engine project into modules as per the structure below. The problem with this new dev workflow is that we have to rebuild the EAR on every change and relaunch the app engine local dev server. This makes us loose 30s to a minute every time we make a change to the code and want to test it.

    /commons
     -pom.xml
    /model
     -pom.xml
    /webapp //app engine module
     -pom.xml
    /apis //app engine module
     -pom.xml
    /ear
     -pom.xml
    pom.xml //main (parent) project pom
    

    In our previous workflow, with the monolithic app, we could use app engine's hot reload functionality, where modifying code in an IDE (e.g. eclipse) would be picked up automatically.

    What do you guys recommend as the best maven config and/or dev workflow in this case? Ideally, a change in any of the modules would not require a full rebuild of the project.

    解决方案

    I am using a similar structure with a small difference. The top level directory has war and ear and then they contain their specific pom.xml. I use Eclipse for debugging, and I am able to hot deploy "most of the time" and I am not using Eclipse plugin, which (I understand) is what you want.

    Directory Structure

    .
    |-- pom.xml
    |-- README.md
    |-- my-ear
    |   |-- devpid
    |   |-- pom.xml
    |   `-- src
    |       `-- main
    |           `-- application
    |               `-- META-INF
    `-- my-war
        |-- build
        |   `-- classes
        |       |-- main
        |       |   |-- java
        |       |   `-- webapp
        |       `-- test
        |           `-- java
        |-- pom.xml
        `-- src
            |-- main
            |   |-- java
            |   |   `-- com
            |   `-- webapp
            |       |-- css
            |       |-- favicon.ico
            |       |-- index.html
            |       |-- js
            |       |-- test.html
            |       `-- WEB-INF
            `-- test
                `-- java
    

    Tools

    • Eclipse Luna without Google App Engine Plugin (or SDK)
    • Maven 3.2.1
    • Google App Engine SDK 1.9.6

    Dev Workflow

    1. If you already have source code, keep it somewhere else and generate a skeleton using mvn appengine command.
    2. Run the first cut with a simple Hello World using only maven and terminal and mvn appengine:devserver command.
    3. Once done, generate the eclipse project.
    4. Import the eclipse project as a Maven project. It will see the jars via Maven. I won't have written this answer before Luna as it required too many tweaks. In Luna, this works automatically.
    5. The step above will create three projects, top level, ear and war each with pom.xml - It's OK.
    6. In eclipse, provide the output directory as war/target directory. This is the step which makes it possible to hot deploy.
    7. In maven ear/pom.xml, add xArgs to appengine plugin for running in debug mode.

      <plugin>
          <groupId>com.google.appengine</groupId>
          <artifactId>appengine-maven-plugin</artifactId>
          <version>${appengine.target.version}</version>
          <configuration>
              <jvmFlags>
              <jvmFlag>-Xdebug</jvmFlag>
                  <jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n</jvmFlag>
              </jvmFlags>
              <disableUpdateCheck>true</disableUpdateCheck>
          </configuration>
      </plugin>
      

    8. Notice the suspend=n.

    9. Run the app engine from outside eclipse using mvn appengine:devserver from the ear directory. I use this command: mvn appengine:devserver > ~/.logs/.appengine.devserver.logs & echo $! > devpid Let's call this Terminal 1.
    10. An advantage of this method is that your console is not captured by Eclipse, so you are free to use a tool of your choice to view it, like multitail etc. I use this simple tail command: tail -f ~/.logs/.appengine.devserver.logs | sed 's/INFO/^[[0;34m&^[[0m/g;s/ERROR/^[[0;31m&^[[0m/g;s/WARN\|WARNING/^[[0;35m&^[[0m/g;s/SEVERE\|FATAL/^[[0;31;47m&^[[0m/g' The above is a difficult to type command. Every instance of ^[ is actually Ctrl+V Esc - it is worth the effort of typing it once. But this is of course subjective and up to you.
    11. In Eclipse, create a Debug Profile for your project under Remote Java Application - select the war project and socket attach options. This step is available on the internet at many places, here is an image nevertheless

    12. Open another terminal, Terminal 2 in the war directory and keep it open in order to run mvn compile install when you need to.

    13. You are good to go. You should be able to integrate your source code by just pasting it at the right place. You should also be able to use standard debugging techniques. Eclipse will compile at the right location and devserver will detect it all right. If Eclipse throws a warning, ignore it.
    14. This works most of the time. Sometimes, you save something that breaks compilation of the whole project, or change a function name being called from a pre compiled class or simply change web.xml which is loaded at start up. Of course then hot deploy will not work.
    15. In such a case, stop your remove debug from within eclipse, complete your tasks, run mvn compile install from Terminal 2. Devserver will autodetect.
    16. Mostly, I hardly need to touch the tail running in Terminal 1. Devserver does not tend to need restart.
    17. Unless I am changing web.xml or refactoring, I do not need to run mvn compile install from outside.


    My reason for giving list of windows (Eclipse, Terminal 1 and Terminal 2) is just to show that Alt+Tab is actually faster than Shift+F7 from within eclipse. It is subjective and of course up to you.

    这篇关于应用程序引擎+模块+ maven的开发工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆