简体   繁体   English

Java项目建设

[英]Java project building

I have some question related to project building in Java . 我有一些关于Java项目构建的问题。

When attempting to find some good examples of projects using Gradle as their building system, I was searching through Google Code . 当试图找到一些使用Gradle作为其构建系统的项目的良好示例时,我正在搜索Google Code

There were some and I tried checking out this project and examined the related build.gradle file: http://code.google.com/p/spock/source/browse/trunk/spock-example/build.gradle?r=1316 我尝试了一些项目,并尝试检查了相关的build.gradle文件: http : //code.google.com/p/spock/source/browse/trunk/spock-example/build.gradle? build.gradle


Now, I can easily build this project using command line and all the dependencies are nicely and automatically resolved. 现在,我可以使用命令行轻松构建该项目,并且所有依赖项都可以很好地自动解决。 However, automatic build also generates an IntelliJ IDEA project. 但是,自动构建也会生成IntelliJ IDEA项目。

So, the question . 所以, 问题

I'm sure there are plenty of Gradle -based projects on the web. 我确信网络上有很多基于Gradle的项目。 How are these building systems like Gradle being integrated with IDE 's? 这些建筑系统(例如Gradle如何与IDE集成?

For example, generated project for IntelliJ IDEA can't be compiled using the internal tools of the IDE and can't be debugged (!) 例如,无法使用IDE的内部工具编译IntelliJ IDEA生成的项目,也不能对其进行调试(!)。

The only thing I can do is extend the test cases , run them and package the final jar . 我唯一能做的就是扩展测试用例运行它们包装最终的jar Is this OK? 这个可以吗? I'm not really used to Java building systems, but I thought they should integrate easily with the IDE . 我不是很习惯Java构建系统,但是我认为它们应该与IDE轻松IDE

What about making the same things with Ant / Maven ? Ant / Maven做同样的事情呢?


I'm probably missing something and if somebody has experience, please help me :) 我可能缺少了一些东西,如果有人有经验,请帮助我:)

Thank you. 谢谢。

To my knowledge, Gradle's IntelliJ support is nearly complete. 据我所知,Gradle的IntelliJ支持已接近完成。 I've successfully used it to generate an IntelliJ project configuration for a fairly complex project. 我已经成功地使用它为相当复杂的项目生成了IntelliJ项目配置。 I haven't had a chance to use it much, as I'm just looking at transitioning from Gradle to Maven, but I didn't notice any problem like you seem to be describing. 我没有太多使用它的机会,因为我只是想从Gradle过渡到Maven,但是我没有注意到您似乎描述的任何问题。 Maybe the build you're using is using an older version of Gradle that didn't have good IDE support yet? 也许您正在使用的构建使用的是Gradle的较旧版本,而该版本尚未提供良好的IDE支持? Can you give some specific examples of things that don't work the way you expect? 您能否提供一些无法按预期方式运行的具体示例?

Edit: Specifically for your problem, I did this, and it worked with Gradle 1.0-milestone-4, IntelliJ 10.5, and JDK 1.6.0_26 on Windows 7: 编辑:专门针对您的问题,我做到了,它与Windows 7上的Gradle 1.0-milestone-4,IntelliJ 10.5和JDK 1.6.0_26一起使用:

git svn clone -r HEAD http://spock.googlecode.com/svn/trunk spock
cd spock
gradle idea

Then, in IntelliJ, File -> Open Project..., navigate to and select .../spock/spock.ipr as the project to open. 然后,在IntelliJ中,选择“文件”->“打开项目...”,导航至并选择... / spock / spock.ipr作为要打开的项目。 I first ran a full build of the project (Build -> Make Project), and hit a problem with spock.util.concurrent.BlockingVariables. 我首先运行了项目的完整版本(“构建”->“创建项目”),然后遇到了spock.util.concurrent.BlockingVariables问题。 I had to tell IntelliJ not to generate a stub for that class. 我不得不告诉IntelliJ不要为该类生成存根。 My Groovy isn't very strong, so I can't tell you why that fixed the problem or what the implications of doing it are. 我的Groovy不够强壮,所以我不能告诉您为什么解决了这个问题或这样做的含义。 After that, I was able to successfully run spock-spring/src/test/groovy/org/spockframework/spring/InjectionExamples.groovy. 之后,我能够成功运行spock-spring / src / test / groovy / org / spockframework / spring / InjectionExamples.groovy。 Then I put a breakpoint on line 38 of that file ( service instanceof IService1 ), and I was able to debug it and break on that line. 然后,我在该文件的第38行( service instanceof IService1 )上放置了一个断点,并且能够对其进行调试并在该行上中断。

It's worth noting that the Gradle build doesn't include all of the modules in that project. 值得注意的是,Gradle构建并未包含该项目中的所有模块。 The default Maven build includes ten modules in total, whereas the Gradle build only has six. 默认的Maven构建总共包括十个模块,而Gradle构建只有六个模块。 The Gradle build doesn't include spock-maven, spock-example, spock-grails-support, or spock-grails. Gradle构建不包括spock-maven,spock-example,spock-grails-support或spock-grails。 If I had to guess, they're probably transitioning to Gradle in phases, and they're not all the way there yet. 如果我不得不猜测的话,他们可能正在逐步过渡到Gradle,而且还没有完全实现。

It's not very clear to me why you are trying to use Gradle, is there some functionality it provides that you need? 对我来说还不是很清楚,为什么您要尝试使用Gradle,是否提供了所需的某些功能? Some feature you find compelling? 您觉得引人注目的某些功能? I have no experience with it, but if you are just trying to build a Java project, I will vouch for Ant using Eclipse IDE. 我没有经验,但是如果您只是尝试构建Java项目,我将使用Eclipse IDE担保Ant。 Ant was the first build program I tried, and I haven't needed anything else. Ant是我尝试的第一个构建程序,而我不需要任何其他东西。 From what I understand, Maven is also quite good, and integrates with Eclipse very well. 据我了解,Maven也相当不错,并且与Eclipse的集成非常好。

i strongly recommend you looking at Maven . 我强烈建议您看一下Maven Maven is not tied to any particular IDE, although i can imagine its plugin can be found for your IDE, it has plugin support for Eclipse . 尽管我可以想象可以在您的IDE中找到它的插件,但Maven并没有绑定到任何特定的IDE,它具有对Eclipse插件支持。

Maven is one of the promising build, and it does more than build actually. Maven是有前途的构建之一,它的作用远不止是实际构建。 It is a key enabler to continuous integration build systems, ie hudson + maven + continuum + ... 它是持续集成构建系统(即hudson + maven + continuum + ...)的关键推动力。

It has dependency management, such that you may specify what external libraries you wish to use, and it downloads transparently and links to your build, both during compile and build time. 它具有依赖项管理,因此您可以指定要使用的外部库,并且可以透明地下载并在编译和构建期间链接到您的构建。

It has "standard" packaging practice that is being adopted, and it is quite sane and simple. 它具有被采用的“标准”包装实践,并且非常理智和简单。

Overall i have seen more projects started with Maven of recently, and the project itself is part of Apache and is quite active. 总的来说,最近我看到更多的项目是从Maven开始的,该项目本身是Apache的一部分,并且非常活跃。

Maven can't be compared with ant as in Maven vs Ant , Maven is more than a build script than Ant is. 无法将Maven与ant进行比较,就像在Maven vs Ant ,Maven不仅仅是Ant之外的构建脚本。 There are many things that can be achieved using Maven through plugins, (such as Maven Cargo plugin which simplifies deployment to application servers). 使用Maven通过插件可以实现很多事情(例如Maven Cargo插件可以简化向应用程序服务器的部署)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM