Maven. Exclude some file from uploading to local repository - maven

I am creating an AWS Lambda package using maven-assembly-plugin. It generates several ZIP files in the target directory.
The Maven Plugin maven-install-plugin uploads all the JAR and ZIP files located in target subdirectory every time I deploy the project. These files are quite heavy. I don't need them in the local repository.
Is the a way to exclude them from uploading to local repository.

You can set the <skip> parameter of the maven install plugin to true. You do this in the <configuration> section of the plugin definition.

Related

Maven pom to zip config files from GitHub and jars from artifactory

Requirement:
Need to push config files and jars from artifactory to UCD for deployment.
Config files are present in GitHub repostiory.
Jars (not needed for build but needed to start application in UCD) are present in artifactory.
What would be the general process to follow, in order to copy config files from github and download/copy jars from artifactory and package everything in a zip file to push to UCD?
You might consider:
the maven download plugin to get the files you need from an URL (like a GitHub repository or an Artifactory one)
the maven assembly plugin to build your archive
configuring on UCD side the source of your Nexus package to deploy, although there is a urbancode plugin maven-ibmucd which could be handy (not tested)

Customize build and release role in maven

I have a Non-Java Maven project. By default the deploy goal generates a JAR file, however I would like to generate a zip file instead that should be published to nexus at a later phase.
If I create the zip file manually and place it in the target folder, Maven is not publishing it to nexus, it only publishes the JAR file automatically created.
So my question is: Is there any way to upload to nexus all the content of the target folder? If not, how do I tell Maven not to create a jar file and create a custom zip instead?
Maven has the deploy:deploy-file goal which can be configured in your pom.xml It can be used to upload arbitrary files, including zips.
You can avoid the creation of a jar if you change <packaging> to pom.

Download all files under a groupId from Maven Repository through command or Java program

Our project is using Nexus Repository Manager to store all the jars.
Along with the jar I see that under a group there are other files like pom.xml, .md5, .sha1 file. I am in need of these files at our server startup.
Is there a way that I can download all the files under a particular group programatically using Java/Curl command/mvn dependency command at runtime?
Maven also uses local repository for caching. The default location is Default: ${user.home}/.m2/repository. You can check this setting in file settings.xml under [maven_dir]/conf/.
To update dependencies, use -U option. i.e. mvn clean install -U
Do not forget setting nexus repo inside pom.xml file http://maven.apache.org/pom.html#Repository
I could do it with the simple approach.
Club all the xmls into a JAR/ZIP file and upload that zip file under my groupId to the Maven Repository.
Then programatically use CURL/WGET to download the zip and unzip the contents of that zip file (using any available utility) at runtime.
Put all XMLs under a zip file.
Use mvn deploy to load this zip file to my Maven Nexus Repo.
Then Programatically during runtime, download the zip file using simple weburl call to that ZIP file.
Use ZIP4J or any other library to unzip the contents to my required output folder
Pick files from this server when needed during the flow.
Hope its helpful to someone somewhere sometime. :)

How to access the folder of the downloaded artifact using properties?

I have an artifact in Nexus containing a ZIP file, let's say
<groupId>com.ddd.tools</groupId>
<artifactId>mytool</artifactId>
<version>2.1.0</version>
<classifier>bin</classifier>
<type>zip</type>
Now, I have another Maven project which depends on the above artifact so that I declare the above in the project's dependencies.
In the current project's workspace I download and unzip the content of the above ZIP archive using the command
mvn clean dependency:unpack-dependencies
which unzips the content to the folder ${project.build.directory}/dependency/mytool-2.1.0.
My question is how can I access the subfolder mytool-2.1.0 using Maven properties or any other variables?
Today it's version 2.1.0 but tomorrow it could be any other. In either case I'd like to have a method that works independent of it.
The background of the question is that in my build process I download several artifacts with ZIP files from Nexus, unzip them and then I want to copy them to other destinations which use other folder names.

How do I find out my Maven deploy directory?

I have my source code in Git and use Maven to deploy it to an Archiva repo.
I somehow don't exactly know where my deploy directory is. I would like to copy a kar file there so that it can be deployed when Jenkins builds it.
your deploy directory is groupId/artifactId/version depending in wich repository you deployed (SNAPSHOT,release, or thirdpary), generally you should build in a different project your kar file and then use as a dependency in the other project.
You shoud not copy any files in a repository without a pom.xml.
Or you can just deploy with deploy:file

Resources