I am writing a program that needs to run JUnit tests that are located in an external project. That external project needs to be cleaned and built to ensure that the JUnit tests are run correctly. I can't require the user to go in and clean and build manually, so I need to automate this process. It needs to be done inside of a java program.
I was thinking I could possibly use ant, but then I would have to potentially call an external shell script to clean and build the project. I would prefer to do it all in one project, but if ant is the only way to go, please let me know.
I can't require the user to check the build automatically option in eclipse, because the projects we work with are really big and take a lot of time to build.
How do I automate the eclipse process of cleaning and building a project in java?
Since I am running the project using gradle, I was able to figure out and automate the process of cleaning and building with gradle by only requiring the user to run another project rather than use eclipse.
Related
I'm using IntelliJ IDEA (15.0.3) to write a project in Scala over Spark.
Every time I build using the following command
./gradlew clean build idea
IntelliJ pops up the message 'No Scala SDK in module' and asks to setup the Scala SDK version.
Is there a way to permanently specify the SDK version so that building with Gradle won't override it?
In general you don't need to run the idea task with every build. That task generates IDEA project files so you're able to open the project from within the IDE - you usually only need to run it once when setting up the project. Running the task over existing project files can (partially) overwrite them, depending on how the task is configured and apparently does override the SDK configuration changes made in your case.
So just running ./gradlew clean build when building should solve your issue (unless I'm missing/misunderstanding part of your question).
I am using Jenkins for continuous integration win my scala application. I have two modules in every project. One for Scala and one for UI (Angular with bower and npm). Sometimes, in the UI project, some of the commands are not getting executed properly. However, if I clean the jenkins workspace and run again, it works fine.
I am looking for some plugin or another solution by which the workspace can be cleared before every 10th build or so.
Using Workspace Cleanup Plugin , it is possible to clear the workspace before/after build. But then the build takes more time to complete since many files/jars needs to be downloaded
I'm looking at setting up a continuous integration server for running selenium and testng unit tests.
I know you can do so by using maven or ant, but I don't want to add a 2nd build system into our project. I've read all about it, another team here is using maven, but I'm trying as hard as I can to avoid it. (Would appreciate not turning this into an Ant or Maven debate.)
From what I've read, if I was using Intellij their TeamCity product could do this no problem from the project config files - but we're not (unfortunately, I'd love to), we're using Eclipse. If we were using Netbeans, apparently everything is already stored as an Ant project so that wouldn't be a problem.
Curious if anyone has had any success setting up a continuous integration server with an Eclipse project, without adding in another build tool to the project. We can do this without a problem on a developers local machine, seems like it shouldn't be to hard to do for an integration server...
Edit: I found another stack overflow topic on how to run the eclipse build from the command line -
Build Eclipse Java Project from Command Line
"eclipsec.exe -noSplash -data "D:\Source\MyProject\workspace" -application org.eclipse.jdt.apt.core.aptBuild"
I tried it out, and manually copying over the results into Tomcat definitely works (though you end up copying .class files rather than a .jar file). Most of the continuous integration products say they can use any command line tool to do the build.
Still wondering if anyone has done it before though...
We want to use Hudson/Jenkins to build our project which is currently realized entirely in Eclipse. From what I can tell, there are various ways to go from A to B, or E to H, as it were: export as Ant script, export as Maven script, export as Runnable JAR while creating an Ant script for that, etc.
All of the above seem to have in common that between "This runs in Eclipse" and "Hudson produces something that runs" there are multiple steps which are independent, for example, you can change your project, commit to SVN and trigger a Hudson build, but unless you specifically remember to "Export as Ant Script" in between, it will fail.
Is there a "one in all" solution ? I'm not worried about the amount of clicks, but instead about the various steps in between that, to make matters worse, are only needed sometimes. In short: I am looking for something that goes from "I can click on the 'Run' button and it works" to "Hudson produces something that works" without every developer having to remember every optional step in between.
Ideas ?
Edit: All of the answers so far seem to suffer from the same issue: it's all parallel development. You have your Eclipse Run Configuration, and you have Maven/Ant/Whatever build. If you change your run config, you have to then remember later to change your Maven/Ant/Whatever build, commit it, and then HOPE that all other developers notice the change to the Maven/Ant/Whatever build during their daily SVN Update, manually open the file, inspect the changes and then duplicate those changes in their own run configs. That seems like it's just begging for bugs and mistakes, isn't there anything that's properly integrated with the Eclipse Run Configurations ?
Hudson can build Maven or Ant projects, so the first step is to get a reproducible build with either tool, which you only need to set up one time. Then you need to take that pom.xml or build.xml file and actually commit it to Subversion. This is necessary since Hudson won't open Eclipse and will instead use the command-line to execute a build.
Then you can setup a new Hudson job that will watch Subversion for any changes. Your developers can use their normal workflow, where they use Eclipse to do builds and commit changes to source control when they're ready. Hudson will see it and pull down a fresh copy of the code base, and then will do its own compile and will report back any problems.
Personally I prefer Maven2, since I know Hudson has solid integration with it and will do things like run your JUnit tests. Eclipse used to be painful with Maven, but now there's the m2eclipse plugin.
I'd try http://www.ant4eclipse.org/.
It allows you to build your eclipse project from an ant file. From the first paragraph here: http://www.ant4eclipse.org/node/6 it sounds very much like what you want. With ant4eclipse ant will access your eclipse project and then it should be able to build through Hudson.
The aim of the ant4eclipse project is to avoid (or at least: to reduce) the redundancy of Eclipse and Ant configurations. More precisly: it consists of Ant tasks that are able to read and work with some of Eclipse's configuration files.
Migrating to Maven, Hudson has great first class intergration with Maven.
Maven 3 + Archiva makes a very potent build system. Of course there are other Repository Managers but Archiva does just enough for what I need.
Once you get Maven, you really wonder how you did without it up until then. A dedicated private Repository Manager helps this greatly, that is why Archiva is important to the mix.
I have seen that if I right click on a project in Eclipse and choose to run it on a server, then I can see output which means the project is running.
If everything is working fine without Maven, what's the point of using it. How is it different than simply running it via eclipse?
Maven is a build tool (build manager, in fact), similar to ANT. The main job of any build tool is configure the project, compile using required projects and do the final packaging. A build script in your project gives a blue-print of project's deliverable structure. This frees you from any configurable dependencies on specific IDE like Eclipse. All you need to know is the standard command to perform the build and you can build your code almost anywhere.
Now, back to your question, why wouldn't do it in Eclipse?
For a simple project and small team Maven is an overkill. You can easily communicate the configuration, IDE to use, and instruct any special steps to be taken. In big projects, however, there exits lots of loosely coupled dependencies. To start with, there will be different settings for developer machine build, test build and production build. There are requirements to run automated test, integration tests, store the build package (artifact) to a commonly accessible repository, update versions of various modules.
Obviously, if all the steps mentioned above is done manually there are chances of missing a step. Moreover, the manual process is time consuming.
Ideally, you should prefer a tool which fits the best for you. If you think that you're able to achieve what you required without Maven, it makes sense to not to use Maven/build-tool just because everyone uses it.
It is suggested to study automated deployment, this will give you bigger picture on what all the stuffs that you can do with build tools. And if you do not feel that it adds any value to your current process, you probably don't need Maven or any other build tool right now.
Your question does not make much sense. Do you expect your users to access your application from eclipse? If so that is a very strange set up in my opinion.
Perhaps your question should be about how to build your project. Maven provides you a way to centralize dependency libraries across the enterprise. It lets you automate your build process (most likely in conjunction with a CI server like hudson, cruise control, etc). It lets you automate your unit testing. Maven makes the packaging of app very easy to do. A developer does not have to follow arcane set of steps to package an application. You add the right plugin and maven takes care of it as part of the build life cycle. All of this magic can happen because of the principle of convention over configuration. There are many more benefits, I just named a few.
Maven is not replacing how you run the app, rather how you package the app, automate that process, and manage the dependencies of your app.
Some links on why someone should use maven:-
Why maven ? What are the benefits?
why I use Maven
Why you should use Maven
Use Maven