I have an library, published as a jar, at Maven repo, and this lib provides some Groovy DSL for user objects. Is it possible to provide IntelliJ GDSL with this lib?
I mean, put it somewhere at META-INF inside a jar, or at Maven's pom.xml, and it will be automatically processed and used by IntelliJ IDEA?
Is there any way to make similar thing for Eclipse too?
Yes, just add your jar with *.gdsl file to your library classes and the GDSL script will be executed in the user project automatically.
Related
My project inherits it's compile dependencies from parent and I have no control over it - can't change them to provided. Additionally, I have added another dependency 'a:b:1.0.0' to my project's pom. I want to include only 'a:b:1.0.0' with it's own dependencies (recursively ) to my uber jar.
Seems like neither assembly nor shade plugin doesn't support such case.
How this could be done ?
Thanks
Shading recursively has some significant disadvantages. Especially, the problem of duplicate files from multiple dependencies being overwritten with only a single version of the file. This can cause some pretty annoying problems to troubleshoot at runtime. You'd be better off using something like spring boot to build a standalone jar where instead of shading files into a single hierarchy, will embed dependent libraries into itself as a subdirectory and include on the classpath for you.
http://docs.spring.io/spring-boot/docs/current/maven-plugin/repackage-mojo.html
I am currently working in a Java project, and we use maven to build the final jar. There are two ways to build the jars as we all know, i.e. one single jar with-dependencies, and a jar without dependencies. In the latter case, we need to add dependent jars to the classpath as well.
In principle both can work, personally I prefer one jar with dependencies, but in the project team members decided to use separate jar without dependencies. So hereby I would like to know which choice is better?
This question has no answer, since it depends on what you need to do.
If you're writing an utility package or component, that could be a dependency of another project, then there's no point in having all the dependencies inside it - it's better to leave dependency resolution to a dependency manager, like Maven.
If you, instead, are writing a full application packaged as a jar, I mean something with a MainClass that can be executed with java -jar myjar, then having the dependencies together will make distribution easier.
Consider that, for instance, if you're writing a webapp, that'll be packaged as a WAR, it normally comes with dependencies.
I am wondering a nice way of post processing a war produced with maven to add libs to it.
I have a war that is generated by maven. This war has many dependencies with scope provided because the application server is meant to provide them through shared libraries (don't blame me for shared libs...)
I am trying to change this behaviour and to have a standalone war. I'd like to find a way to generate a war that contains those additional jar.
I have tried with an assembly to add the jars and repack it but w/o any success. Mainly because I didn't find a way to add dependencies from maven within an assembly.
Any point, suggestions or anything else that could help ?
I have two maven projects, the second project extends some classes of first project. I want to create the jar file with all dependencies of first project and include it to another project as dependency. I am searching this since long time, is it possible to do it?
I am new to maven, any help on this would be highly appreciated.
Thanks
If you just want to add the dependencies to another project you add the second project dependency to your new project and the first one will be inherited and automatically included. This is what is called a transitive dependency. Read more about it in the free book Maven: The Complete Reference.
If I understand you right, you want to create a uber-jar containing all dependencies, right ?
Please refer to this question How can I create an executable JAR with dependencies using Maven?
In the second project's POM file, specify the first projects maven co-ordinates (groupId,artifactId,version,packaging) under the 'dependency' section. It will transitively acquire all the dependent artifacts.
Although it is possible in Maven to generate a standalone jar with all its dependencies. For that purpose, you can use the maven-shade-plugin. ( Reference )
There are two ways you are create a fat jar. You include the jar itself in the jar of dependent. You will not have much control in this case and the maven assembly plugin would do the work. Alternatively, you can unzip the jar and zip everything together to create the new jar. You have to decide which one best suits you. If you have multiple versions of same class, then include the whole jar in the new jar would help, but if the versions are coherent, it's best to create a jar by unzipping and zipping everything. For the second procedure, I recommend using the maven shade plugin to create uber jar.
I wanted to know the right way I should act.
I have a project which I have compiled into a jar file using maven plugins.
Now, I need to add javadoc , source code , of my project and my tests.
How should I do it?
Basically maven have plugin to deal with such cases.
If I use those plugins I end up with :
project.jar
project-sources.jar
project-javadoc.jar
project-tests.jar
Is this the right way?
Thanks!
Yes, what you're describing is generally considered the correct way to build javadoc, source, and test jars with maven.
The Maven cookbook describes how to attach source and javadoc arifects