When I build my project from the command line with Maven, I can pass in a property using
-Dsomeproperty=true
For example:
mvn clean package -Dsomeproperty=true
How do I do the same when building in Eclipse?
You have to do the following steps (and sorry, I have no environment to prove it, just from documentation):
Create a maven build by choosing on the selected pom of your project Run > Maven...
Enter the relevant goal, and press add in the arguments table.
Enter there your system property as name: someproperty and value: true.
Then start your maven build by pressing Run.
See the following resources for details:
Creating a Java application launch configuration
Set System Property for JUnit Runner (Eclipse) to test a Spring Web App
After having access to an Eclipse again, here are some screenshots:
The first shows how to configure an existing build (in Eclipse named a run configuration) with the relevant property. and the second shows the command that is then triggered (with the include -Dsomeproperty=true).
I do not know if there is an easy way to configure the default run configuration. You may provide an empty one, enter there the parameter, and copy then that run configuration adding the additional parameters later. The copy button is on the left top the second one (with the red rectangle marking it).
Related
I want to run a particular class in Ecplise called 'RunCreateNetwork'.
However, when I choose Run as and create new Application Config, it doesn't allow me to choose project, where this class is located.
Give me an advice how to run it, if you can, please.
As Som noticed correctly, your project doesn't seem to be a Java project (for whatever reason). A Java project would have a 'J' in the upper right corner of the Icon.
Check your project configuration if it has a Java nature. How you do this is alread described here.
I've recently been tasked with working on an existing eclipse project that makes use of Builders to run Ant tasks under given conditions. I've never heard of Builders before yesterday, and I'm having difficulties getting the project to work in IntelliJ.
First of all, I would like to know if there is a way I can effectively trick Ant into running from a different base directory than what it already does. Consider the following screenshot from Eclipse:
Here, project A is running an Ant task in a local build file that extends a build file from project B. As you can see from the Base Directory setting, it is different from that of A. When I try to run the task from this build file in IntelliJ, I get build errors because certain directories do not exist in the folder for project A -- they are located in project B.
Secondly, this Builder is set to trigger on Manual Build and Auto Build, but my understanding is that this only triggers if the project the builder is attached to gets built. As far as I can tell, in IntelliJ, I can set an Ant task to trigger before or after a build, but it seems like this will be for the whole project, instead of just the relevant module that represents this Eclipse project. Is there a way I can make it only apply to a given module, or will I have to trigger it for changes to all modules?
My situation demands I have two copies of the same project. One is for development, the other is for debugging, testing and single stepping to understand the existing workflow.
As a consequence I have two copies of the same project. I would like both copies to behave exactly the same way except that the first project should not take part in debugging. All the JDWP [Java Debug Wire Protocol] attempts to connect and debug the remote Java process should be with respect to the untouched dedicated copy of the project that was checked out recently.
Is there a way to accomplish this?
You can create multiple debug/run configuration for the same or different projects in Eclipse.
Assume that you have a single Java project and you want to
Test your application with some VM arguments and
Without any VM arguments.
Then Go to Debug->Debug Configuration and select Java application. Create debug(launch) configuration for your project and select main class of your Java project.
For 1 go to Arguments tab in the VM text area add the arguments
For 2. Leave this blank
Thus you can debug single Java project with multiple debug configuration.
In your case you MUST create debug configuration ONLY for that project you want to debug.
I'm trying to create a "Java/AspectJ application" run configuration for my Maven built project. Because i'm using Spring aspects i have to include the spring-aspects artifact in the run configuration's Aspect Path list. I'm adding it via the "Advanced.." button selecting "Add Classpath variable" and extending from the M2_REPO variable. So in the end i have a classpath variable entry in the list like this with a blue dot icon next to it:
M2_REPO/org/springframework/spring-aspects/3.1.3.RELEASE/spring-aspects-3.1.3.RELEASE.jar
However once i save it, Eclipse automatically replaces it in the launch file with the real path of the JAR on my machine making impossible to share the launch file with others since it's hard coding the entry to my environment.
Editing the launch file by hand doesn't help either because once i run it Eclipse replaces the expression the same way as above.
Is there any way to solve this?
The solution was to create the entry under the "Aspectj Load-Time weaving application" run configuration category instead of the "Aspectj/Java Application". For some strange reason the path of the Aspect is kept in it's unresolved format only with the first run configuration type. I guess it's a bug.
Obviously this makes the launch time longer because it does the waving in run time aswell. However i can't seem to find other solution.
Is there a way to add build steps to a "run configuration" in Eclipse?
My project uses an applet that should be built before starting the web application. So I'd like to configure Eclipse to do this single step before actually running the application.
I know I can do it with Ant/Maven, but I wonder if there's a way to do it in Eclipse.
Thanks
For a classic launching (Java or Java Applet) configuration, no. Not directly.
For an External Tols launcher, not directly either.
The idea would be:
to not build your applet every time you modify your main project
make sure it is built when you want to launch your webapp.
For that, you could define two projects:
one for the compilation of your main project.
the second (depending on the first) for the compilation of your applet.
Your launching configuration would then run with the second project (which includes the first)
If the option "Build automatically" is selected, the second project shouldn't run without being compiled first.