Eclipse's embedded Maven doesn't accept run-time arguments - eclipse

I have configured jar.version as dynamic input to pom.xml
<artifactId>xyz</artifactId>
<version>${jar.version}</version>
I tried to configure maven goal in eclipse's run configuration as
clean install -Djar.version=1.0.1
I also tried to add jar.version=1.0.1 in parameter section of maven run configuration.
But this parameter is not accessible by maven build process. Need help here.
I am able to access it if i use external maven (and not eclipse's embedded one) then below command works well
mvn clean install -Djar.version=1.0.1

Related

How to create a launch configuration "Java Application" that uses Maven Dependencies from scope=test for its classpath?

This question is a bit related to this one.
Problem Description
I want to create a new Launch Configuration of type "Java Application" (not JUnit!) that will start some kind of stand-alone test tool that we have.
This test tool is also needed during the Maven Build phase integration-test and is therefore included in the pom.xml. However, the dependency is in <scope>test</scope>.
The problem is that the Maven Dependencies which I add to the classpath of my launch configuration does not contain the dependency to this test tool library which makes it obviously impossible to e.g. find the MainClass that shall be run.
Question
Is it possible to create a launch configuration that uses the Maven Dependencies of the scope "test"?
Remarks
Note, that I do not want to create a "Maven Build" launch config as I want to run the test tool as a stand-alone Java application.
EDIT
"Solution"
I ended up creating a JUnit Test case that does nothing but calling the main method of the stand-alone application. It is very dirty but it gets the job done.

Force the use of an alternate POM file in eclipse

In my maven project I usually use the POM file named pom.xml. I have a second POM file though (call it pom_alt.xml), which I occasionally use to perform a very different build of the same project. To do so I specify the -f option in the command line
mvn clean package -fpom_alt.xml
as suggested by man mvn:
-f,--file
Force the use of an alternate POM file.
Now, when I am coding in eclipse I usually need maven to use pom.xml, but sometimes I should code or debug while the other file pom_alt.xml is used instead. Is there a way to tell the eclipse maven integration to use that file? Currently I am temporarily copy-pasting from pom_alt.xml to pom.xml since I seldom happen to need that, but you can see that's not optimal.
I am with Eclipse IDE for Java EE Developers, Mars Release 4.5.0.
UPDATE
I could build from the command line or use Run As Maven build as in
Carlos Andres' solution, but ideally I would like to define a persistent setting, like a property or preference. This because I find nice if the POM file can be fixed while I am doing things like running as Java Application and test cases, or executing on a server. Processes that require a project clean or server restart are often triggering a maven build with the default POM.
Check that M2E - Maven Integration for Eclipse is installed on Eclipse. Once that is installed go to the project and press right click
Next, put the command that you want to execute
This option allow you to save the commands, and the next time all your commands will be saved.
To execute the command recorded go to

maven error with build all argument

I am a beginner in maven. I have just installed maven 3.3.1.
I have already added the m2_Home pointing to the installation directory in the environment variable.
I created a quick demo project for testing purposes named tutorialsJava.
In my eclipse, I have configured the external tools configuration for different maven arguments
for e.g I am using the build-all argument
Here when I run the project using the maven Build all command, I have the following error.
I have tried several solutions on the web like changing the arguments in the path
I have also tried with this solution but without any success.
Why am I getting this error and how can I fix it?
I would suggest that you use M2Ecilpse which is a Maven integration for Eclipse: http://eclipse.org/m2e/

eclipse Run As with Maven dependency not automatically included

I have moved a jdbc dependency to Maven but I still need to add it manually to my Eclipse run config for it to be found at run time using eclipse Run As (see picture).
What do I need to do for this jar to be added/found automatically at runtime in Eclipse?
The problem was that for some reason the "Maven Dependencies" library was not added to the classpath of my eclipse run config.
To add the "Maven Dependencies" library I had to copy the following line into my run config file:
listEntry runtimeClasspathEntry
containerPath=org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER
A bit hackish, but works fine now.

Grails Project - Common Java Project Dependency in Eclipse

All,
We have standard java projects that contain our common data model, common util classes, etc...
What I can’t seem to figure out is how, to make my Grails project (in Eclipse) have a dependency on the other standard (non Grails) java project in the workspace. When I add the project in the “Java Build Path” the project doesn’t show any compiler errors, but it when I run “Grails Tools -> Refresh Dependencies” or attempt to run the project (run-app) it fails.
This seems like it would be a pretty common thing, but I have searched all over the web and have been unable to find a solution. We are not using maven in our environment. Since we build Eclipse RCP applications on the client side, we use OSGI manifests to manage our project / bundle dependencies.
You can use linked source directories to include the Java or Groovy dependencies in the grails project and you need to set the output directory to Project/target/classes (these configurations go into the grails project preferences in Java Build Path options -> Source Tab).
The change in the output directory allows Eclipse to detect changes in the dependencies and auto load it when running the app using grails run-app.
You can use autocomplete and debug the sources of the dependencies with this configuration.
I prepared a step and step process that includes screenshots for Java and Groovy here
The documentation includes information on customizing the build.
You can add this to your BuildConfig.groovy:
grails.compiler.dependencies = {
fileset (dir:"/path/to/jars")
}
That should get you started.
If the dependencies are not stored in an Ivy/Maven repository then AFAIK your only option is to copy the dependencies to the lib directory of the Grails project.