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.
Related
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.
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.
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. :)
I can create mvn archetypes in my company's nexus. However, in the folder structures, I want to include some files that do not contain a file extension. These our proprietary files for a certain feature and I need them in the archetype.
How can I upload these non-extension files to my mvn archetype? Thank you
Hey im new to maven and i was wondering if anyone knew if i had a bunch of files in a directory, can i make that directory a local repo for maven. the projects in there are not maven projects but would i be able to somehow downlaod those files onto another location using maven?
this is how the folder is organized:
patch
--new folder
----versions (multiple folders which contain zip files)
is there a way to getting the version folders and copying that to a different directory with a maven command like
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=org.hibernate:hibernate-entitymanager:3.4.0.GA:jar:sources -DoutputDirectory=/home/-Dmdep.useBaseVersion=true
You were very close to the correct solution - same plugin, different mojo:
$ mvn maven-dependency-plugin:copy-dependencies -DoutputDirectory=/path/to/output
This will dump all dependencies into the location of your choosing.
The -DstripVersion=true argument is useful if you want to have the jars by their canonical name without the version suffix (ie log4j.jar vs. log4j-1.2.17.jar).
Hope that helps.