JavaScript的Web应用程序和Java服务器,构建所有的Maven中使用或用于咕噜web应用程序? [英] Javascript web app and Java server, build all in Maven or use Grunt for web app?

查看:196
本文介绍了JavaScript的Web应用程序和Java服务器,构建所有的Maven中使用或用于咕噜web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在做AngularJS的Web应用程序,我们喜欢用鲍尔的依赖管理和咕噜建筑,运行测试的想法等。(约曼

We are doing a web application with AngularJS and we like the idea of using Bower for Dependency Management and Grunt for building, running tests etc. (Yeoman)

服务器与使用Maven的Java做的,所以我们当然会用一个简单的 MVN安装创造一切(Web应用程序+服务器)

The server is done with Java using Maven, so of course we would like with a simple mvn install build everything (web application + server)

那么接近你了,为什么?

So what approach you took and why?

1)把它们作为两个不同的应用,其实他们。因此,使用不同的建筑方法/工具是可以接受的。

1) Treat them as two different applications, which in fact they are. So using different building methods/tools is acceptable.

2)忘掉咕噜鲍尔,使用Maven插件来构建,运行测试,管理依赖于Web应用程序。如果是这样的话,哪些?

2) Forget about Grunt Bower, use Maven plugins to build, run tests, manage dependencies for the web application. If that is the case, which ones?

3)使用Maven exec插件调用步兵构建前端Web应用程序。我认为这更象是一个黑客不是一个解决方案。

3) Use Maven exec plugin to call Grunt to build the front-end webapp. I see this more as a hack than a solution.

4)其他。

办法更容易与詹金斯整合是一个加号。

Approach easier to integrate with Jenkins is a plus.

在此先感谢!

推荐答案

有关在Java工具包的每个资产管道工具,有一段时间我都来了几个结论,工作后:

After working with about every asset pipeline tool in the Java toolkit for a while I have come to a few conclusions:

有许多工具在那里,但最流行的是JAWR和Wro4J。与这两个最大的问题是,他们大多是犀牛基于(WRO4J现在有一些节点支持)相比,基于节点的工具Rhino是狗缓慢。你还必须考虑到JavaScript的工具正在迅速成熟,所以你应该寻找一个可以迅速移动的工具。

There are a handful of tools out there but the most popular are JAWR and Wro4J. The biggest problem with both of these is that they are mostly Rhino based (WRO4J now has some Node support) and Rhino is dog slow compared to Node based tools. You also have to consider that the JavaScript tooling is rapidly maturing so you should be looking for tools that can move quickly.


  • WRO4J - 支持是巨大的,Maven和Eclipse集成是伟大的插件列表为广泛的框架具有足够的灵活性,与一些苦劳,你可以写任何你需要的插件。如果你只局限于一个基于Java的资产管道,这是肯定要走的路。与Wro4j问题是,它是相对缓慢的基于节点的工具(即使它揭开序幕节点进程)。
    结果
    为了给一些真实世界的数字编译和连接含有降低了25捆资产,CoffeeScript的CSS和JavaScript的使用在2013的iMac Wro4j的节点支持的RAM 16G使用犀牛和15秒〜当约需〜35秒。使用咕噜 +节点约需我微不足道的MacBook Air 2秒。

  • WRO4J - Support is great, Maven AND Eclipse integration are great the list of plugins is extensive and the framework is flexible enough that with some elbow grease you can write a plugin for whatever you need. If you're confined to a Java based asset pipeline this is for sure the way to go. The issue with Wro4j is that it is slow ( even when it kicks off Node processes ) relative to Node based tools.
    To give some real world numbers compiling and concatenating 25 asset bundles containing LESS, CSS CoffeeScript and JavaScript takes about ~35s when using Rhino and ~15s using Wro4j's Node support on a 2013 iMac with 16G of RAM. Using Grunt+Node takes about 2s on my puny MacBook Air.

JAWR - 的集成和功能列表是pretty好,但文档不是很大,写你的自己的插件可以是一个有点棘手。当我最初写这个帖子JAWR在4年的间隙的中间,但现在回到正在积极开发作为2014年一月的如果你选择研究Java工具,这是值得调查。

JAWR - The integrations and feature list are pretty good but the docs aren't great and writing your own plugins can be a little tricky. When I originally wrote this post JAWR was in the middle of a 4 year hiatus but is now back under active development as of Jan 2014. If you choose to investigate Java Tools this is worth investigation.


  • 步兵 - 这很容易,有一个梦幻般的插件生态系统和社区是巨大的。如果你需要做的,你可以打赌有它的一个插件的东西 - 甚至可能是一个又咕噜的创造者写的。步兵的主要批评是,它是配置驱动这是个非常简单的设置,但不是节点的方式。另外值得一提的是,咕噜任务不容易组合的这么一个复杂的JavaScript建立管道咕噜可能不理想。

  • Grunt - It's easy, has a fantastic plugin ecosystem and the community is massive. If there is something you need to do you can bet there is a plugin for it - possibly even one written by the creators of grunt. The major criticisms of Grunt are that it is configuration driven which makes for a very setup easy but is not the "Node Way." It's also worth mentioning that Grunt tasks are not easily composable so for a complex JavaScript build pipeline Grunt may not be ideal.

咕嘟咕嘟 - 咕嘟咕嘟是快速成长的替代步兵。默认情况下,它的并发,并使用流,以避免临时写入文件系统,它可以大大加快您的构建。咕嘟咕嘟很地道,而且对code>配置的重视,虽然这给你一个很大的权力这是不理想的没有在JavaScript中的核心竞争力的球队。

Gulp - Gulp is the fast growing alternative to Grunt. Its concurrent by default and uses streams to avoid temporary writes to the file system which can considerably speed up your build. Gulp is very idiomatic and has an emphasis on code > configuration and while this gives you a lot of power it's is not ideal for teams that don't have a core competency in JavaScript.

唯一潜在的挂断了基于JavaScript的工具是你必须有节点,的 NPM 咕噜-CLI /的gulp~~V 需要做编辑的任何计算机上。如果您没有访问您的CI机器或不使用神器根据部署,这可能是一个强买强卖。
结果
结果
这个集成到你的Maven项目是pretty容易,你有不少的选择。你可以使用Maven 蚂蚁运行插件,则可以运行的蚂蚁EXEC任务并从Maven的调用或最重要的是你可以使用的maven EXEC任务
结果
下面是code使用exec插件,如果这是有帮助的任何人这个融入Maven的生命周期。

The only potential hang up for JavaScript based tooling is that you will have to have Node, npm and grunt-cli/gulp on any machine that needs to do the compilation. If you don't have access to your CI machines or are not using artifact based deploys this may be a hard sell.

Integrating this into your Maven project is pretty easy and you have quite a few options. You can use the Maven ant-run plugin, you can run an ant exec task and call it from Maven or best of all you can just use the maven exec task.
Below is the code to integrate this into the Maven lifecycle using the exec plugin if this is helpful to anybody.

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.2.1</version>
      <executions>
        <execution>
          <phase>prepare-package</phase>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <executable>grunt</executable>
      </configuration>
    </plugin>

这篇关于JavaScript的Web应用程序和Java服务器,构建所有的Maven中使用或用于咕噜web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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