I am trying to use Maven in Eclipse, and I am trying to package my project. I right click on My pom.xml, I go to Run as, but there is no "Maven Package" option there.
This is how it looks:
What am I doing wrong, and how can I get that option?
If you do the Maven install it should also do the packaging. You will find the resulting artifacts in the directory called target.
If you want to run only mvn package, I believe you need to select the option number "3 Maven build ..."
Related
I have a non-maven app engine project. I need to include the following library/project into it: https://github.com/UltimaPhoenix/luceneappengine. Without using maven at all, how do I make this work? I need step by step details. I have been trying and my code will not even compile. I am using eclipse.
Looking at the pom.xml I have figured that I need to download luceneappengine, which I did at http://search.maven.org/#search%7Cga%7C1%7Cluceneappengine. Do I need any other jars?
First of all, download Maven to be able to build the project. After that, just use "mvn install" to produce the *.jar of luceneappengine (the result will be stored in the "target" folder of the project). However, it will probably need some extra dependencies. To obtain them, use "mvn dependency:copy-dependencies -DoutputDirectory=$TARGET_DIRECTORY". This command will download all the required jars into the specified $TARGET_DIRECTORY.
I followed the following tutorial (https://github.com/kolorobot/spring-mvc-quickstart-archetype) and imported the project to eclipse.
However, i am getting the following errors in my pom.xml file, and also in all the java classes.
I have attached the screenshot.
POM.xml
Java classes
I have updated my Post
PROBEM VIEW
In the eclipse buildpath, make sure you have the maven dependency jars downloaded under "Maven Dependencies"
If you dont see, run the below command to download the same.
mvn clean dependency:copy-dependencies package
This may sound silly, but in my experience I have seen this working. Do a Project Clean in eclipse and do a maven build
There is no Maven dependencies classfolder in your screenshot. Have you tried right-clicking the project name -> Maven -> Update Project?
Update Unbound classpath var.M2_REPO
You need to fix your Maven installation. Go to Window -> Preferences -> Maven and have a look at: Installations and UserSettings
from command line I can write
mvn install -Pauto-deploy
Is it possible to store this command in my eclipse maven plugin. I want to execute this command by click.
I see only standart things in maven menu:
build
clean
install
test
I want see at this list my_autodeploy_command
I am sure it is possible but I don't know how.
Can you show how?
where can I write mvn install -Pauto-deploy ?
Somewhere here?
UPDDATE
for taringamberini
The dialog is the correct one. Install, the lifecycle phase to run up to, is put into the goals field, your profile (auto-deploy) is put into the Profiles field (without -P):
You could also copy the full line (without leading "mvn") into the Goals field
Is it possible to store this command in my eclipse maven plugin.
Yes, it is:
In the Package Explorer view right click your Maven project
choose Run as and Run configurations...
right click on Maven Build (node added by your eclipse maven plugin) and choose New
Compile the filed Name for example with clean_test_install
Compile the field Base directory browsing your maven project directory
Compile the field Goals for example with clean build test install
click Apply and close the Run Configuration window
Now, in the tool bar, if you click on the drop down menu at the right of the Run As ... button you can see the clean_test_install entry.
UPDATE
You can do it in maven plugin in eclipse as below.
Go to debug configuration eclipse --> New configuration in Maven Build
Specify Goals as clean -install and select base directory as project which you want to build. You can also skip test if we want in configuration
I had an ugly/complicated maven command which launched my project. And On Windows, I wanted to launch it in eclipse - to see the console, and not under a command prompt - where you can't see the console clear. The Maven command was something like:
mvn -am -pl web package -DskipTests -P link-repo,tomcat-run,local-jive -Dfile.encoding=UTF8
So blackbuild answer:
"You could also copy the full line (without leading "mvn") into the Goals field"
saved my life!
I just copied the maven command in Goals field and it worked!
I joined an SVN server and checked out the source files a project from that server. In the Eclipse editors, when I hit Ctrl + Space, I got the following error message:
This compilation unit is not on the build path of a Java project
What should I do to solve this problem?
Read this guide on how to use maven projects with eclipse
http://maven.apache.org/guides/mini/guide-ide-eclipse.html
Taken from the above link :
Reason why you get that notice :
Eclipse needs to know the path to the local maven repository. Therefore the classpath variable M2_REPO has to be set.
Solution
Execute the following command:
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
Restart your Eclipse IDE (if you already have it open) for this change to take effect.
You can also define a new classpath variable inside eclipse: From the menu bar, select Window > Preferences. Select the Java > Build Path > Classpath Variables page
For Simple Projects :
If you have a simple java project which is made up of only one module, using eclipse is very simple. To generate the eclipse project files from your POM you execute the following command:
mvn eclipse:eclipse
If you have created or checked out the project with eclipse, you only have to refresh the project in your workspace. Otherwise you have to import the project into your eclipse workspace (From the menu bar, select File >Import >Existing Projects into Workspace). In the latter case the project (directory) should not be located in your workspace, because eclipse might come into trouble, especially if you want to use eclipse as the scm client.
For a more detailed explanation refer the above link.
Import project as maven project.
File-> import-> Maven-> Exiting Maven Project-> Next-> Root Directory-> Browse your project from Disk
Follow these steps:
Right click project in Eclipse. Select to Run As → Maven build...
In Goals add eclipse:eclipse
Select Run
Wait for build to finish
Right click project in Eclipse. Select Refresh
This is due to the issue in build path .
If you had imported the project as Existing Maven project, do the following to resolve the issue.
Right click in the Package Explorer -> Maven -> Update project.
Or select the project in package explorer and perform Alt+F5 which is the shortcut for the maven project update.
Execute mvn eclipse:eclipse on command line and once the build is successful, refresh your project in eclipse. This resolve the issue.
I have a maven project which won't compile due to an unresolvable reference from another project's artifact.
When I run eclipse:eclipse and open it up it shows an auto fix suggestion of "Add project 'project2' to build path of 'project1'". If I click this everything works. So project1 can clearly see my project2 reference, but doesn't quite use it as expected.
However, once I delete all the files generated for eclipse the error resumes because whatever reference eclipse created has been removed. How can I get this project2 in the project1 build path manually. I already have it listed in the pom as below:
<dependency>
<groupId>group.id</groupId>
<artifactId>project2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
In "Project properties > Maven" menu you should check "Resolve dependencies from Workspace projects".
When I run eclipse:eclipse[...]
This sounds like you are using the Maven Eclipse plugin. You should probably rather use m2e, which is the recommended way to integrate with Maven now. This will also obviate the need to run mvn eclipse:eclipse. Instead, just import your Maven project into Eclipse, and it will pick up everything automatically.
After you set "Resolve dependencies from Workspace projects" as described in polypiel's answer, things should just work (TM).
If you have maven nature to both your projects, you should do mvn clean install to both the projects, so they will be installed in your local repository and will be available for other projects to use as dependencies. Or just right click to both the projects in eclipse and choose Run As --> Maven install