Exclude resources in Appassembler Maven Plug-In - java

I have a Java Maven project, where I use a commercial, third-party dependency which I'm not allowed to redistribute. I use Appassembler Maven Plugin in my project to collect all dependencies and build a startup script.
Now I want to zip the Appassembler target folder and send it to a client, including all open source dependencies, but excluding the proprietary dependency. How can I configure Appassember to exclude this JAR?

Related

How add dependencies to generated sources

I developed my own maven plugin, which has a goal of generating sources. These sources have dependencies from my plugin code and are not compiling without it.
Is there any way to add plugin code dependencies to generated sources?
Or more precisely, is there any option beside adding plugin and dependencies separetly in pom?

Consume / import local fat jar as plugins in maven

I have recently used the Maven Assembly Plugin and also the Maven Shade Plugin in order to create a FAT JAR containing a specific plugin and its dependencies.
I did this because during the build phases our company uses private servers with no access to the internet so I can't depend on public repositories.
So I have this FAT-JAR-WITH-DEP.jar and to test if it works with my module, I removed the original plugin jar from the maven repo and pasted this instead.
I also removed its dependencies. the POM file remained the same.
What happens is that it still tries to download the dependencies because of the pom file.
How do I use a FAT JAR as a plugin that already includes it's dependencies?
Sorry, but building such a fat jar is not a good idea. You are trying to manipulate the "inner structure" of Maven.
If you want to use Maven in an offline environment, copy all the relevant plugins and dependencies to your company Nexus/Artifactory. The easiest way to do this is run a build once against a public repository and then copy all the stuff that was downloaded through Maven.

Export maven as jar file with all dependencies

I have my own java library created as maven project and has some dependencies included in pom.xml
I want to export project as jar and include it into others maven projects.
The problem is that I need to copy all dependencies from pom.xml of my library into maven projects where is imported my library to make it to work.
How to export my library to not be necessary to copy dependencies of my library.
That is easy to do; the central feature of Maven is that it manages the project dependencies for you.
You need to mvn install your project from the command line; that will install the jar and the pom files to your local repository.
You can then include your library as a Maven dependency in other Maven based projects; Maven will resolve the (transitive) dependencies for your project.
Normally you don't need to list all the dependencies in the project that imports your library. Maven should fetch them for you. What you need to do is to declare dependencies in your library.
Make sure you declare correct types of dependencies. Here is more info. In your case you need to make sure that dependencies you want to copy to the downstream projects are marked as 'compile'
There are tools that make 'Fat' jars by copying all dependencies inside. But they are mostly used to build the final project such as a deployable WAR file or a desktop app. Not in case of the libraries

Import Maven Project as Dependency into Gradle Project

I went through this link to import a gradle project as dependency into another gradle project. Is there a way to include a maven project as dependency into a gradle project?
If that Maven project is built somewhere else and deployed to a Maven repository, you can specify the artifact it produces as a simple compile dependency. If this Maven project is somehow a subproject of a Gradle multi-project build, I suppose you could hack it to work by simply ignoring the Maven POM file and perhaps adding a build.gradle to that project.
To use the solution described on the link that you provided - both projects must be gradle and included in gradle settings. Therefore you can use project closure to compile and depend on the project without building it explicitly.
I am not aware of any way to do this with maven project. I understand you use some maven plugins that you dont want to rewrite in gradle as simply can not find any equivalents etc. Often had that problem.
In this scenario I would suggest to build maven project and depend on a built jar in your gradle project.
Otherwise you could probably amend sourcesets in your gradle project to include maven classes. But I think it would be to complicated.
If I would be you I would turn it into gradle and try to replicate what you had using maven or just build the artifact and depend on it in dependencies closure.
Gradle is not that new anymore and there are many plugins that are superseding old good maven stuff.

Maven and regular Java can be used in single eclipse project

In Eclipse IDE, it is displaying as a Maven project and Java project. How different are they from each other. Can we make use of regular jars and maven jars in a single project? Else, have to use maven and regular java jars separately?
A maven project is a java (or scala) project which uses apache maven as dependency management and build tool. Normally, you don't need to add "regular" jars as almost every dependency is on the maven central (https://search.maven.org/) which you just add to your pom.xml, the actual jar is then automatically downloaded from the remote repository.
If you have a jar which is not on the maven central (i.e. e third-party jar or a jar from an own project), you can install this jar in your local (or enterprise) maven repository, see e.g. https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Categories

Resources