I never had to do this before but maybe someone else has.
I want to run "mvn --encrypt-master-password".
I'm on a machine with only Eclipse and m2e. I could of course download and set up maven on my hard drive with the appropriate JAVA_HOME envvars etc, but I figured I'd try to get it done quickly in Eclipse.
m2e quickly gives a "no goals have been specified" error.
I could put in a dummy goal but I can't see any way to enter a mvn command line parameter (as opposed to a 'goal parameter')
This is theoretical now since I'll go and do this on a command line somewhere, but I'd like to know if it's possible.
For a one-time password encryption job you can set --encrypt-master-password <your password> as a goal in the Maven build as already specified by flafoux (Run Configurations > Maven Build > New build > ...).
But this is not secure since you password is stored in a configuration (unless you delete it right after the execution). And this is also not handy since you need to update a job manually for every encrypted password you need...
ps: https://maven.apache.org/guides/mini/guide-encryption.html says since 3.2.1 Maven should ask for the password if not specified, but it does not at least at my eclipse lune having Maven 3.2.1 embedded - may be it does at more recent verions.
You can set goals with build configuration.
Create a maven build configuration (Run as > Run Configuration... Maven builds , and add goals.
more explanation : http://books.sonatype.com/m2eclipse-book/reference/running-sect-running-maven-builds.html
Related
I have a few Maven projects in Eclipse 2019-6 that each include the maven-javadoc-plugin (v2.8) in their pom (which I don't want to modify), but in some cases I'd like to skip building the javadoc.jar when I run maven package or install through Eclipse (because for a couple of these projects, the javadoc.jar takes a fair amount of time to build).
Is there an argument I can pass through the Eclipse m2 run configuration that will allow me to skip the javadoc.jar when I run a package or install locally?
I've searched fair amount for tutorials or documentation of m2 run configurations in Eclipse and haven't found anything much more than "here's how to set up a Maven run configuration" with no extra options or advanced configurations.
I really appreciate any help!
You can try adding maven.javadoc.skip=true in the build parameters table of your launch configuration (equivalent to -Dmaven.javadoc.skip=true in a CLI build)
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
Question: When running Maven in Eclipse, how do I send the console output to file?
I would like to achieve this using a pom setting or a maven plugin. I do not want to modify the run configurations or the maven system settings.
For reference, I am using Windows 7, Eclipse Luna, Java 6, Maven 3.
As per official command line options you could use -l,--log-file <arg> which provide the:
Log file where all build output will go.
As such, running:
mvn clean install -l output.log
Would not print anything to the console and automatically redirect the whole build output to the output.log file.
If you don't want to type it every time (or you actually don't want to use the command line) and you want it as default option (although rare case I would suppose), you could use new command line options behavior available since version 3.3.1 and have a .mvn folder where the concerned pom.xml file is located and a maven.config file in it simply providing the following line:
-l output.log
That is, the .mvn/maven.config file replaces MAVEN_OPTIONS just for its project, locally where it has been created, with the options it provides, not impacting other builds as per Maven settings of MAVEN_OPTIONS.
This is an IDE agnostic solution (it's a new built-in feature of Maven) and local to a project, but still not provided via simple POM editing, which cannot be achieved since the first phase of Maven default life cycle phases is validate, which:
validate the project is correct and all necessary information is available
That is, during the build, hence when the build has already started (and generated output), it validates the pom.xml file, hence too late to redirect build output at that stage based on some POM properties/plugin.
Go to run as and choose Run Configuration -> Commons -> Select a file.
This should redirect your output to the file you specified.
According to this you can try editing the ${MAVEN_HOME}/conf/logging/simplelogger.properties. I gave it a quick try and maven's output is redirected, but anything else writing to stdout (tests, for instance) still writes on the console
What about creating a fork of M2E and modifying it to read the output file for the launch config from pom.xml
https://github.com/eclipse/m2e-core.git
A possible solution is setting the output format in the mvn file. For example, in the directory /usr/bin, add the desired output informing the path the log will be saved at the end of exec "$JAVACMD" \ line: | tee /home/maven-log.log.
However, it only works when the maven is called by terminal line; when called by IDEs, like eclipse, this solutions does not work.
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
I would just like to setup a new GWT project in Eclipse and use Maven for dealing with all the jar jungle. I used gwt-maven-plugin with this instructions, but I can't get the project to work in Eclipse.
What I've actually done:
Created a maven project using the archetype gwt in command line.
Imported the projet in eclipse using import > existing maven project
While doing that I had errors saying:
gwt-maven-plugin:2.3.0-1:generateAsync - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:i18n - "No marketplace entries found to handle"
gwt-maven-plugin:2.3.0-1:exploded - "No marketplace entries found to handle"
These errors don't go away even if I ignore them on the import.
How can I make these projects working? Is the problem that I skipped the "process-resources" setting? (There is no such setting in the latest version of m2e.)
Should I even use gwt-maven-plugin? Is there any other way of making a GWT project to use Maven? Or – is there any other way to fight with the jar jungle? What does GWT guys use?
I use Eclipse Indigo with m2e plugin 1.0.0 and Google suite plugin version 2.3.3.
Eventually I gave up Maven. As one other developer said "good ideas and bad code build communities faster" , I also remember my experience with Maven on all the projects: very promising on the beginning, but eventually you get to some problems and end up working more with configuring Maven than actually dealing with your own code.
I decided to manually copy needed .jar-s into /lib folder. I spent some time due to transitive dependencies, but LESS than dealing with Maven and now I have things under control. If sometime in the future working with libraries will become an overhead, I will consider using Ivy.
If someone wishes to stick with Maven, I lately found a very useful link by Google team:
http://code.google.com/p/google-web-toolkit/wiki/WorkingWithMaven
They recommend using their sample projects and not gwt-maven-plugin archetypes (due to issues). I agree. They also provide needed pom lifecycle changes for Eclipse Indigo.
According to a recent post on the gwt-maven-plugin mailing list the Maven integration is not complete for Eclipse Indigo, since the M2Eclipse 1.0 release has brought about a large number of changes. The suggested workarounds from David Chandler, Google engineer, are:
You can run "mvn package" on the command line or right-click on the project > Maven > Run as > Maven build.
The plugin execution failures you're seeing can be resolved by adding lifecycle mapping metadata as in the sample POMs. They are only needed for Indigo. You should not get these errors in Helios or when running mvn package from the command line.
Disclaimer: The following guidelines are for Windows users. These steps are on the basis that, they have worked when tried by the replier and doesn't guarantee fulfledge working unless experimented by self and tried with proper prerequisites.
::Creating a simple gwt project using archetype::
Following are few commands that can be used to create a simple gwt project "Web Starter Application":
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 org.apache.maven.plugins:maven-archetype-plugin:generate
mvn -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0 -DgroupId={project packaging} -DartifactId={application name} -Dversion=1.0 -Dmodule={module name} org.apache.maven.plugins:maven-archetype-plugin:generate
(The value of archetypeVersion can be 2.3.0 or any higher stable version.)
Few coordinates are required by maven to create the gwt project. They are as follows:
groupId
artifactId
version
module
The first command doesn't take any of the above coordinates hence, we need to supply them at the time it executes. Notice that the archetype goal is mentioned right at the beginning of the command. It is mandatory to give the archetype goal.
The meanings of these coordinates can be found here.
One of the best ways to start with understanding maven is this.
The second command doesn't consider the module name hence, you will be prompted to give it at the time the command executes.
The third command is equivalent to running it in batch mode where you just have to confirm the inputs for groupId, artifactId, version, module as mentioned in command itself.
Once any of these commands gives a BUILD SUCCESS result, then navigate to the just-now-created project folder from command line and execute the following command:
mvn gwt:run
It should start the project in Development Mode so that you can Launch the Default Browser to run the project or Copy the URL to clipboard and navigate to it through any browser.
Good luck with the execution.