Maven Eclipse Runtime Plugin Dependency - eclipse

We have a multi-module maven project that was recently converted from Ant+Ivy. One of the modules is a legacy custom pluggable component which looks for plugins on the classpath and loads them. Another module in the multi-module project is a plugin implementation that is run by the aforementioned plugin.
When running our custom application server from an eclipse run configuration, we must include each of our plugins on the classpath. As we build within the eclipse workspace these plugins are not compiled to a jar. Hence, there is no jar artifact to include.
If I add the plugin module project as a dependency in the eclipse run configuration, its transitive dependencies (supplied by Maven) are not inherited. Hence, class not found exceptions occur when the plugin is found and loaded by the Application Server.
The problem here is that upon importing the multi-module project, the m2e plugin does not set the maven container to be exported. Thus the missing transitive dependencies.
Is there any way to make this work whilst still running in eclipse using "build in workspace" for both the Application Server component and its plugins.

Ivy is just a dependency management tool where as Apache Maven is a software project management.
Means It can handle all process in software development like compiling,building it to jars, search for depencies,linking, etc.
you no need to give your jars in classpath instead put it in your local repository or edit the pom.xml to fetch from remote repository.
this link http://ant.apache.org/ivy/history/2.0.0/use/makepom.html

Related

Eclipse OSGi (Kura) Plugin and Maven

I have a simple basic question. If I develop plugin for Kura in eclipse with maven, can I use dependency feature of Maven? I mean, when I use Maven for my Spring projects, I simple add dependency to pom.xml file and I can use in my project. Since I run Spring project on my local machine, dependent .jar files can be used runtime. This time, I will deploy my plugin to another device (Raspberry) , I have to put everything in the bundle .jar package. Can Maven do this or should I add dependent .jar files to classpath manualy?
You can use maven shade plugin to build the so called uber-jar - one jar that will contain your project along with all the dependencies.

Eclipse/Tomcat publishing unnecessary/problematic dependencies

So first off, a little background.
I am working on converting an Eclipse Java Web Project to Gradle. We use the Vaadin framework and currently manage the project with Ant/Maven/Ivy. We have another project that contains common code that the web project depends on. In both projects our library files, JARs, are simply included in the source and committed to our VCS. With the switch to Gradle we will be using the preferred method of pulling our dependencies from a repository; mainly Maven Central.
I have completed creating the Gradle build scripts that correspond to our current Ant build scripts. I have one Gradle build script for each project, as well as one at the root for configuration injection along with the settings file. I am using the java and eclipse plugins for both projects and additionally the war and vaadin plugins for the web project.
Now to the problem. When I use Gradle to construct the WAR it works perfectly and the WEB-INF/lib directory contains only the JARs that I would expect, based on the dependency configuration. However, when I use Tomcat inside Eclipse to publish the project I end up with a bunch of additional JARs in the WEB-INF/lib directory. Most of the JARs are harmless and just unnecessary, which is why I have excluded them from the WAR, but there are a couple that are actually problematic because Tomcat already has them. In one case it just ignores the JAR and I get the usual message of:
[Tomcat] validateJarFile(*) - jar not loaded.
In the other case I actually receive exceptions in the console, which is troubling even if the application appears to work correctly. I also noticed that all the dependencies associated with the testCompile configuration are also being published, which really doesn't seem right.
The exact offending JARs are tomcat-jdbc and servlet-api-2.5. The tomcat-jdbc JAR is required for compiling our common code. The servlet-api-2.5 JAR is actually just a transitive dependency of vaadin-client-compiler. I have removed the dependency for the vaadin-client-compiler in our web project, because it doesn't appear to be necessary, but it looks like it is still being pulled in by a configuration in the vaadin plugin for Gradle. However, in both cases I am using the providedCompile configuration of the war plugin to exclude them form the WAR.
So my question is, how do I keep Tomcat/Eclipse from publishing these JARs? How do Gradle and Tomcat/Eclipse communicate, or do they at all? From what I can gather it seems that Gradle and Tomcat/Eclipse only communicate indirectly via the .classpath, that the eclipse plugin for Gradle modifies. Also, I have tried the eclipse-wtp plugin for Gradle. It did not seem to resolve the issue because the problematic JARs were still being copied. I am actually not even sure whether I need to use this plugin or if I can just simply use the eclipse plugin.
I should also add that I did install the Gradle Integration for Eclipse "plugin" via the Eclipse Marketplace. With that I used the Configure -> Convert to Gradle Project option that it adds as well as the Gradle -> Refresh Dependencies functionality that it provides. Other than that, I found it to be a little buggy so I've mostly been running Gradle via the command line.
Below is the output of running gradle -v on my machine:
------------------------------------------------------------
Gradle 1.10
------------------------------------------------------------
Build time: 2013-12-17 09:28:15 UTC
Build number: none
Revision: 36ced393628875ff15575fa03d16c1349ffe8bb6
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.8.0_05 (Oracle Corporation 25.5-b02)
OS: Mac OS X 10.9.3 x86_64
Please let me know if additional clarification is required. I assume I must be doing something wrong or missing some configuration because surely my scenario is quite common. Many developers use Tomcat inside Eclipse to test web applications locally and with the popularity of Gradle I would be surprised if someone hasn't run into this before. It would seem the main difference with our switch to Gradle, as far as Tomcat/Eclipse are concerned, is that our dependencies are now being loaded from a repository instead of being linked directly in the source.
Any help is greatly appreciated.
However, when I use Tomcat inside Eclipse to publish the project I end up with a bunch of additional JARs in the WEB-INF/lib directory. Most of the JARs are harmless and just unnecessary, which is why I have excluded them from the WAR, but there are a couple that are actually problematic because Tomcat already has them.
This is a known problem with the gradle eclipse tooling. The problem is that it doesn't understand about dependencies with 'provided' scope. See this issue for some details:
https://issuetracker.springsource.com/browse/STS-2380
There is a workaround for this problem. Some common dependencies that 'cause problems' can be globally excluded via a list of regexps you specify in the preferences. Open menu "Window >> Preferences >> Gradle >> WTP". That's where you can add regexps that will be used to exclude jars from the 'deployment assembly'.

IvyDe Eclipse plugin - how to exclude jar files

I set up IVY with Ant and able to build a spring mvc project. I have configurations such as provided, compile, test, runtime etc and setup classpath as needed in build.xml for various tasks, ear file, unit test etc.
However I recently installed IvyDE plugin to manage classpath to automate everything from eclipse IDE. provided jar files are app server specific and i don't want them to be included in the classpath of eclipse. Is there a way to not include some dependencies (jar files) with certain conf.
I guess that the Ivy configuration you want in Eclipse is the "runtime" one. Then go into the configuration of the classpath container in Eclipse and select the appropriate Ivy configuration in the suggested list.
See the online documentation:
http://ant.apache.org/ivy/ivyde/history/latest-milestone/cpc/edit.html
http://ant.apache.org/ivy/ivyde/history/latest-milestone/images/ivy_file_def.jpg

Eclipse not deploy all the jar files for a web app

We have a non-trivial multi-module maven project, then have a single module maven web-app that depends on 2 modules in the larger multi module project.
When we use eclipse to deploy to tomcat, it doesn't deploy all the jars that are required (spring, camel, etc) by the projects in the multi-module projects, but the multi-module jars are present???
But if we were to do an export of a war file on the single module app it includes everything we need spring, camel, and all the multi-module jars as expected? Why do export and deploy work differently and how can I get deploy to work the way I want.
We are using eclipse 3.6.2 with m2eclipse and other plugins. It seems Eclipse Indigo is worst at handling maven projects than 3.6.
This seems to be the same problem that I encounter semi-regularly. Open the build path for the project, and in the Exports tab, check the Maven dependencies checkbox. Do a clean and reploy the webapp.
It may be necessary to remove & readd the webapp to the server, and I usually have to quit Eclipse and restart it.

How can you specify where Maven puts the dependent JARs?

I have configured my POM to include the Maven-Surefire plugin, as well as a dependency to a repository with some Selenium stuff.
After running mvn eclipse:eclipse, my project now has 100 jars, including the Jetty, Spring, and Selenium jars, all at the root of the project.
The project builds and runs fine, but how can I put the jars into a directory so it doesn't look so bad? Is this something I can configure in the POM?
Instead of using the maven eclipse plugin ("mvn eclipse:eclipse"), you could use maven eclipse integration plugin (m2eclipse), all your jars will stay in the local repository.