I have some question related to project building in Java
.
When attempting to find some good examples of projects using 开发者_StackOverflowGradle
as their building system, I was searching through 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
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.
So, the question.
I'm sure there are plenty of Gradle
-based projects on the web. How are these building systems like Gradle
being integrated with IDE
's?
For example, generated project for IntelliJ IDEA
can't be compiled using the internal tools of the IDE
and can't be debugged (!)
The only thing I can do is extend the test cases, run them and package the final jar. Is this OK? I'm not really used to Java building systems, but I thought they should integrate easily with the IDE
.
What about making the same things with 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. I've successfully used it to generate an IntelliJ project configuration for a fairly complex project. 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. Maybe the build you're using is using an older version of Gradle that didn't have good IDE support yet? 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:
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. I first ran a full build of the project (Build -> Make Project), and hit a problem with spock.util.concurrent.BlockingVariables. I had to tell IntelliJ not to generate a stub for that class. 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. After that, I was able to successfully run 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.
It's worth noting that the Gradle build doesn't include all of the modules in that project. The default Maven build includes ten modules in total, whereas the Gradle build only has six. The Gradle build doesn't include spock-maven, spock-example, spock-grails-support, or spock-grails. If I had to guess, they're probably transitioning to Gradle in phases, and they're not all the way there yet.
It's not very clear to me why you are trying to use Gradle, is there some functionality it provides that you need? 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. Ant was the first build program I tried, and I haven't needed anything else. From what I understand, Maven is also quite good, and integrates with Eclipse very well.
i strongly recommend you looking at 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
.
Maven is one of the promising build, and it does more than build actually. It is a key enabler to continuous integration build systems, i.e. 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 can't be compared with ant as in Maven vs Ant
, Maven is more than a build script than Ant is. There are many things that can be achieved using Maven through plugins, (such as Maven Cargo plugin which simplifies deployment to application servers).
精彩评论