Using maven jetty plugin in multi-module project under Eclipse - maven

I am working on a simple multi module maven project under Eclipse using m2eclipse with maven 3 and jetty plugin version 7. One of my module is a jar and the other module is a war which has a dependency on the jar.
Even though the workspace dependency resolution is enabled, the call to mvn jetty:run fails if I don't run mvn install before.
Having read about workspace dependency, I am not sure why a call to mvn install is required. I would like to be able to run the jetty plugin without installing the artifacts to my local repository. Is it possible?
Thanks in advance.

There is an integration module between m2eclipse and the WTP (Web Tool Platform).
WTP allow starting Jetty/Tomcat/... from Eclipse, debugging inside Eclipse, redeploy on change,...
Here is it: m2eclipse Extras

Related

Do we have to include jar files in eclipse project if we are using maven?

I am new to maven.
The POM file in maven contains all the dependencies that we need in our project.
So we don't have to externally add any JAR's to the buildpath in eclipse.Right?
That's right. Maven will download dependencies and M2Eclipse (Eclipse plugin for integrating Eclipse with Maven) will setup a build path for you.
Two Solutions - 1 Using Eclipse IDE
Install the Maven (M2E Eclipse Plugin) if you use older version of eclipse, If you download the latest eclipse.
Point your settings.xml and create a maven project from your eclipse, it is better keep Group Id as com.yourcompany.app Artifact Id as yourProjectName and Version 0.0.1-SNAPSHOT depends on your Architecture Standards set by your company. Also Packaging can be as WAR file for WebApplication, EAR file for Enterprise Application. You can find the numerous list of examples from Maven Site.
2 From Command Line
Install Maven from Apache Maven site, Would recommend to go for the latest version -apache-maven-3.3.9-bin.zip.
Set the Maven Home in the Environment Variables as shown in the below figure.
Edit Your Path variable as %MAVEN_HOME%\bin, verify your installation by using this command from your command prompt. It should display the Maven Home and Java Version, which confirms your maven successful installation.
Paste your settings.xml (C:\apache-maven-3.3.9\conf) given by your build team or Architecture team for accessing your internal repository. And keep a backup of the original settings.xml (which is default download from Maven site)
Run these commands from your command prompt.
mvn eclipse:clean -e
mvn eclipse:eclipse -e (which will automatically set your project build path as shown in the below figure)
It will resolve your compilation issues and your project is ready as an deploy-able artifact

Maven plugin Tycho -> when to use it and when not to use it

What is the purpose to use Maven Tycho plugins. I read here tycho is used for building eclipse plugins and OSGI bundle.
Questions:- Can not we build eclipse plugins and OSGI bundle just by using the plain old maven POM.xml file[by not using tycho plugin].
What does maven need tycho plugin to help it build eclipse plugin and OSGI bundles?
Why should we use Maven tycho plugin to build eclipse plugins and OSGI bundles?
When using maven (or other command line build tools) manifest.mf) in combination with Eclipse (or another IDE) the classpath ends up being written down twice - once in the pom.xml and once in the Eclipse .classpath (or, for OSGi, in the target platform and manifest.mf). This violates the DRY principle.
There are various solutions to this problem. One is something like m2e, where you use the pom.xml to generate the Eclipse .classpath. Alternatively, you can go in the other direction and start by getting things compiling in Eclipse, and then use a maven plugin to convert that Eclipse setup to a maven build. This is what Tycho does, with the extra wrinkle that it works from a PDE manifest + target platform rather than directly from the .classpath.
Maven doesn't have a built-in packaging type for OSGi bundles and/or Eclipse plugins. So unless you want to use the jar packaging type and manually add OSGi specifics, you need a Maven plug-in to help you with this.
Tycho is one of the plugins that add support for building OSGi bundles.

Installing maven and the maven eclipse plugin?

I installed maven from here: http://maven.apache.org/download.cgi
and also installed plugin for eclipse from the eclipse marketplace.
This is a really dumb question, but what's the difference between the two?
both are same thing ? or for differnet purposes ?
do we need both on system ?
Maven itself is the software you can use on your machine. It has nothing to do with Eclipse. You can use it from the command line with the mvn command to execute Maven goals on your projects in the file system.
The Maven Eclipse plugin (m2e) integrates Maven with Eclipse so you can comfortably use Maven functionality from inside Eclipse rather than using Maven as an external tool. The plugin just integrates Maven with Eclipse and needs a Maven installation to work. You can configure the plugin to use the Maven installation on your system but there is no need for one. It can use it's own internal "installation" of the actual Maven software. This would be basically the same as you can download and install yourself but it is integrated with the plugin. It therefor can't be used outside Eclipse.

where to place customer jar in maven project structure

I have a dependency application jar from other maven applications,and currently added it to my application path,
I want to know how this application related jar can be automatically moved my local repository folders.
I think it should be placed in somewhere in maven project folder structure so that when maven build the module it automatically moves to the repository.
Dependent project:
If built with maven, you would issue a mvn install, when building it.
If not built with maven, install it locally using mvn install:install-file
http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

maven does not copy dependencies

I have Dynamic Web Application project in eclipse that was converted to maven project.
Problem is that all dependencies are copied to:
<project>/target/<project>-SNAPSHOT/WEB-INF/lib
not <project>/WebContent/WEB-INF/lib
so when I run application from eclipse, there are no libs from maven and I get some errors.
I assume that application started from eclipse i.e on tomcat server gets it source from <project>/WebContent/WEB-INF/lib.
You should use m2e (Maven Plugin for Eclipse). It automatically adds Maven dependencies to the classpath, so you donĀ“t need them in /WEB-INF/lib while running from Eclipse.

Resources