Is there a way in Maven to build additionally to the JAR file a ZIP file with only the sources and some text files in it?
I've tried using the assembly plugin for that but it seems it always includes the JAR in the ZIP file.
You use the Maven Source Plugin for this purpose.
You can use the includes parameter to customise exactly what it should include, such as your additional text files.
Maven Assembly plugin can solve this for you. You can configure as many zip artifacts as you want and add to your build process.
Related
I am trying to retrieve the implementation title and version for a maven jar module. If I use Myclass.class.getPackage().getImplementationVersion() on the built jar, it works, but the same does not work in a debugging environment where the jar is not built, but classes are available.
I am aware of using the Maven JAR plugin to generate the MANIFEST for a maven jar module. So one approach I am considering is to somehow create a copy of the MANIFEST in the generated sources output folder, which I include in my debug classpath. To achieve this:
Is it possible to generate the MANIFEST file in a custom location? If so, what is the plugin and execution configuration necessary?
If not, in which location is the file generated, so I may copy it my custom location using the maven-resources-plugin?
The Manifest file is created dynamically when the archive is assembled. There is no default way to do this.
The easiest I would come up with is to put a MANIFEST.MF in a resource directory, let Maven filter it and add the directory with a profile. This would mimic the way Maven Archiver creates your MANIFEST.MF. The hard way would be to create a custom plugin around Maven Archiver and pass the very same config as to the JAR plugin and enable it with a profile again.
When I use Maven Shade to build my assembly jar, some properties files will be replaced if they have the same file name, for example, "logback.xml". I have my own logback.xml in my project, however, it exists in other 3rd jars, too.
How can it be configured to use project's properties files in prior?
Thanks.
Hi you can try filtering out files that you dont want to be included. See here.
My custom Gradle plugin contains files which it wants to copy into the output produced by the build that uses my plugin.
How can my plugin access its own files?
All variables I have tried always refer to the project that applied my plugin, but not to the contents of the plugin.
It seems that if files are located in the jar itself it can be loaded via the following construct:
getClass().getResource("resourceName")
I want to include source files also in Maven - War file . Some plugins in maven will do that but they are including source files in classes folder. But my requirement is that when I import the same war file again into eclipse I should be able to work on that war like any other normal war.
Basically I should be able to work on the same war after importing it to eclipse when I build maven project. (I'm using maven3. )
I remember that's not trivial because the war-plugin doesn't support the handy includes-configuration-element you know from the jar-plugin by default.
Therefore I suggest you to use the maven-assembly-plugin to configure the inclusion of your sourcefiles. You only need to define an assembly descriptor, where you list includes and excludes of your war-package. Maybe you can reuse one of the predefinied assembly descriptors to save some time.
I have an existing mvn project which build into a zip file at the end.
now I need to add an external tool to it, the tool is already a single executable so I just need to include it in the final package.
what is the right way to do this?
Thanks,
There are three steps to follow:
Upload your artifact/tool to a maven repository, e.g. on your local maven repository server (Archiva/Artifactory/Nexus etc.)
Use the Maven Dependency Plugin to download your artifact/tool to your project target directory where you assemble your zip file
Use the Maven Assembly Plugin to assemble your zip file