I am currently developing an SDK targetting both servers and Android devices.
My deliverable JAR is JarJar'ed, thus preventing any dependency leaks from happening in client apps (using maven-jarjar-plugin).
However, there is one issue that puzzles me. A standard Maven deploy will ship sources, POM and other things. The problem is that any Maven-compatible build tool (e.g.: Gradle) will first resolve our SDK according to the deployed POM, thus triggering the pointless downloads of my SDK dependencies (remember: they are JarJar'ed in the final JAR!).
How can I deploy my SDK so that any build tool will understand there is nothing but the SDK to download?
That strange, I'm surprised if the jar jar plugin doesn't support it natively. You may give a try to the shade plugin which is also allowing to relocate classes and for sure it creates and deployed a modified pom for your artifact that won't expose your embedded dependencies to others projects using yours.
See :
http://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
http://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#createDependencyReducedPom
cheers
Related
I am trying to set up tomcat server for gwt application. I would like to configure server to update my server side code changes immediately.
While looking for some helpful examples over the web, I found that there are to plugins for maven.
One from:
org.codehaus.mojo (which also provide plugin for gwt in maven echosystem).
And second from: org.apache.tomcat.maven.
What is the difference between them? Which one should I choose for:
GWT 2.7 Maven Project. I will develope app in Eclipse IDE. So I would like to have good integration with it to. F.e.: the Eclipse tab/view "Servers".
From https://tomcat.apache.org/maven-plugin-2.2/
This is the new home for the Tomcat Maven Plugin (previously hosted at Codehaus).
The CodeHaus Mojo (now MojoHaus) Tomcat Maven Plugin is obsolete.
I have Maven archetypes that use the Tomcat Maven Plugin to fire up a server for development, with automatic redeployment of the webapp when classes change, at https://github.com/tbroyer/gwt-maven-archetypes
Note that they use a different Maven Plugin for GWT than the one from MojoHaus (ex-CodeHaus Mojo), one that works much better with multi-module builds.
I've never used Eclipse WTP though (tried it and had too much trouble, probably because I didn't really know how to use it properly though) so I can't really comment, but I see no reason why it wouldn't work.
I am writing an application plugin in Java, and my plugin has dependencies on several third-party JARs. I am bundling these dependencies with my plugin so that I can deploy just a single JAR file.
The host application may also be running plugins from other vendors. Unfortunately the host application puts all the plugins on the classpath, and I am not able to change this behavior. If another vendor's plugin is loaded before mine and uses an incompatible version of a dependency, my plugin could crash.
I am not able to test compatibility between my plugin and other plugins ahead of time. It is also not acceptable for me to say that there is an incompatibility between the plugins--if my plugin crashes, it reflects poorly on my company. The customer does not care why my plugin crashes, they will attribute it to poor programming on my end.
I am looking for a way to prevent other vendors' plugins from interfering with my own. Is it possible?
I've heard of custom classloaders but I'm not sure if that solution will work for me.
You can use Uberjar. What it does is move all your jars/classes to a custom namespace so that none of your classes clash because your dependencies have a different namespace.
You might want to look at maven-shade
You could try to embed an OSGi container in your plugin. This would allow you to run and load dependencies as OSGi bundles in isolation from the system classloader.
Instructions for Felix.
I'm building a Java project that has a dependency on a library. mvn.bat clean install produced the target subdirectories as expected, and the project built fine with mvn.bat clean install as well.
What's not expected is that when I deleted the entire directory of the library, the outer project still built fine, although the library it depends on was gone.
How does this work?
UPDATE: Turns out Maven makes some sort of cache in %USERPROFILE\.m2.
You are most likely thinking of your local repository where everything you install locally (and maven downloads for you from the central repository) is put for later usage.
The behavior you describe is intentional, and allows for building A once and then let B reference it whenever needed, without having to recompile A every time. This is usually very desirable, especially in teams or with large code bases.
Note, that for changing code you should be using -SNAPSHOT artifacts. They are treated slightly differently.
Your dependencies are always downloaded into .m2/repository.
If you want to have some predictability on downloaded libraries in your team, you can put in place a repository manager like Nexus : https://repository.apache.org/index.html#welcome
Instead of downloading dependencies from Maven central, your developers will download their dependencies from this repository manager.
I'm having some issues making the maven google app engine plugin work properly.
First of all, I'm not even sure if the archetype I'm using is the correct one, their examples show version 0.7.0 but it seems like never versions exist (i tried 0.9.1 and that works), where can I find a overview of what versions of the plugin is available?
Secondly, the archetype seems.. messy, I don't like the package structure and it doesn't seem to actually include the GAE and GWT dependencies. I have to manually add them to my project in Eclipse, which kind of defeats the purpose of using maven. And how come they are breaking the gwt maven plugin? I know that one includes the actual gwt jars as maven dependencies?
I'm fairly new to Maven, but I have been using the gwt maven plugin for a while, and I'm very happy with everything about it. Is there any way I could just their archetype to do the base project and add the gae plugin to it?
UPDATE
I suspect the problem I'm seeing with the GAE maven plug-in is in regards to undefined properties in the POM. I have no idea if its due to error these aren't set-up or if its due to me actually have to manually set them up. The documentation on this plugin is sparse.
Thanks for the answer below, but I really don't want to add another archetype into play. I think the best solution for me is to try and adapt a GWT maven project manually, to include support for GAE.
I've used the archetype like so :
http://code.google.com/p/gae-mvn-archetype/
to generate a GAE project template.Then manually added my other dependencies. This got me a usable project which I can deploy to GAE and everything.
Also, for Eclipse importing, once the template project was done, I've imported it into eclipse using the m2_eclipse plugin :
http://m2eclipse.sonatype.org/installing-m2eclipse.html
(note that i've imported it into Eclipse as a Maven project, NOT as an Eclipse whatever project)
This imported the thing into eclipse with all the necessary dependencies and without errors.
I have a project I need to release the source for. The problem I have is that I need to create a source release for all code that we have developed. The code is across multiple projects, but I want to leverage maven so that only the source for the jars we are actually using is released.
For example:
core code project (multi module maven project)
web app project (multi module maven project). Contains we app module plus some supporting jar modules. Depends on some jars from core code project.
Now I want to release all the source for the web app project but only the source for the core code project that the web app uses.
Can I do this with maven?
I have a feeling it is possible with assembly plugin and source plugin but it is not clear to me how to put this together.
First of all your question is bit unclear. let me assume certain things and proceed.
I believe that following is your folder structure.
web app project
some source code folder
pom.xml
core code project
some source code folder
pom.xml
Take the core code project and change the version from previous version in pom.xml.
let 's say if it was 1.0 change it to 1.1
<groupId>core code project related</groupId>
<artifactId>core code project</artifactId>
<name>core code</name>
<version>1.1</version>
Make your changes to accomodate the web app project in core code project.
later,
in web app project add dependency for core code project in pom.xml
<dependency>
<groupId>core code project related</groupId>
<artifactId>core code project</artifactId>
<name>core code</name>
<version>1.1</version>
</dependency>
In this way, 1.1 version of core project will have only web app related code.
Currently we are using this method. Hope it helps. let me know if you want something else.
I have a feeling it is possible with assembly plugin and source plugin but it is not clear to me how to put this together.
If I understood the question correctly, one solution would be to create an "aggregator" project listing all wanted modules (the relevant modules from the webapp and the relevant modules from the core) and to use the source:aggregate goal from the Maven Source Plugin.
I'm unsure why you want to do this, the pom from your web app project will explicitly list the versions of your code dependencies used, so you can find the source easily. It sounds like you want to store the same artifact twice. So if your web app uses core-x-1.2.3.jar and core-y-4.5.6.jar you would produce a web app sources artifact containing the source from both those core jars in addition to the actual web app source?
You can use the maven versions plugin to update your web app pom to use the latest versions of your core dependencies, I've automated that by running a shell script in a CI server in the past. That means whenever you release a new version of your web app you will be using the latest release of your core code, and all you need to do is update your web app pom from version control.