At my work all development uses Java technology, and we use Nexus to manage our Maven repositories. But for a new project, the build requires dll and exe artifacts. Is it possible to put those windows binary files into a Nexus repository? Is there some plugin to make this simpler? Is what I'm trying to do crazy?
I use Nexus to store all the binary dependencies that I download from the internet.
You can upload the files using the Nexus GUI or use the Maven command line as follows:
mvn deploy:deploy-file \
-Durl=$REPO_URL \
-DrepositoryId=$REPO_ID \
-DgroupId=org.apache.maven \
-DartifactId=maven \
-Dversion=2.2.1 \
-Dpackaging=zip \
-Dfile=maven.zip
This will generate the POM for your zip package automatically.
To retrieve dependencies, you can just navigate to the Nexus URL, or use a generic dependency manager tool like ivy:
java -jar ivy.jar -dependency org.apache.maven maven 2.2.1 -retrieve [artifact].[ext]
Related
I have a custom created service mix feature which is generally a features.xml file. Now i want to upload it to Archiva maven reposistory and use it to install it as a service mix feature. What will be the packaging type to refer to a file with .xml extention.
To install in service mix we use command features:addUrl mvn:a.b.c/abc/1.0/xml/features.
I am not able to make it work When i try to upload with a.b.c as group Id, abc as artifact Id, 1.0 as version and pom as packaging type. What am I supposed to do to make it work?
you can use the following archetype to generate a karaf feature project, customize it and then build it with maven using 'mvn install'
mvn archetype:generate \
-DarchetypeGroupId=org.apache.karaf.archetypes \
-DarchetypeArtifactId=karaf-feature-archetype \
-DarchetypeVersion=2.2.6 \
-DgroupId=my.company \
-DartifactId=my.company.feature \
-Dversion=1.0-SNAPSHOT \
-Dpackage=my.company.package
for more info, see http://karaf.apache.org/manual/2.2.6/developers-guide/archetypes.html
I need to have my own libraries in Maven repository, and I only need these my own libraries (about 2-7 libs). Is it possible to copy these jars to some local folder and then use that as repository in Maven?
Assuming these libraries only need to be available for your local build, you can just install them in to your repo from the cmd line:
mvn install:install-file -DgroupId=<your_group_name> -DartifactId=<your_artifact_name> -Dversion=<snapshot> -Dfile=<path_to_your_jar_file> -Dpackaging=jar -DgeneratePom=true
You can use any artefact/group/version you likr - but these then need to be used in your pom when listing the dependency
I have another project which contains static content (css, images, JS, etc.), and I need that to be copied to the web root directory of jetty for testing. In that project, I output a zip file packaging up all of the images, CSS, etc.
I have several of those virtualhost projects for different clients and my question is, how do I unpack the zip file that was already installed into the maven repository to the jetty web root?
#Update:
Embedded error: Unable to download the artifact from any repository
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId= com.virtualhost -DartifactId=something
-Dversion=0.0.1 -Dpackaging=zip -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=c com.virtualhost -DartifactId=something-D
version=0.0.1 -Dpackaging=zip -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[i
d]
com.virtualhost:something:zip:0.0.1
Walter
It should be possible with dependency:unpack than you could bind on prepare-package phase. See Unpacking specific artifacts for an example (in you case, use a <type>zip</type>).
I wonder whether I can setting up a private maven repository based on my svn.
The svn can be accessed via http.
If yes, then what should I do? Just uploading the architypes is enough?
If yes, then what should I do? Just uploading the architypes is enough?
While subversion is not really made for that, yes, Maven can deploy through WebDAV so it is possible (a lot of people are actually doing this for their google-code projects).
If you want to set this up for an existing maven project (and have the created artifacts deployed to your SNV repository during the deploy phase), adapt the solution described in Hosting a Maven repository on Google Code.
If you just want to add a particular artifacts, use the deploy:deploy-file goal:
mvn deploy:deploy-file \
-DrepositoryId="internal" \
-Durl="dav:https://server/repo" \
-Dfile="some-jar.jar" \
-DgroupId="my.groupid" \
-DartifactId="my-artifactid" \
-Dversion="1.2.3" \
-Dpackaging=jar \
-DgeneratePom=true
Under GNU/Linux, you can paste this command as is; under Windows, run it on one line without the \.
The question shouldn't be can you but should you. Yes you can. No you shouldn't. Instead of using a tool designed to manage source diffs for binary storage, instead get an artifact repository manager like Nexus to manage the binaries. Repository managers have tons of features designed especially to host, share, promote, secure binaries that you don't find in a typical scm. For example an scm has no capability to appropriately deal with maven snapshots.
If you want more information about why you should use a repository manager, take a look at the documents here.
I have a library that I distribute using maven 2. The typical user of this library doesn't use maven to build their applications, but is likely somewhat familiar with maven and probably has it installed.
I'd like to document a "simple" one line command they can use to download my library's artifacts to their local ~/.m2/repository without requiring that they set up a pom.xml to do it.
I thought there was a way to do this, but I can't seem to find it after looking through the install:install-file and dependency plugin documentation. I tried things like:
mvn install:install-file -DrepositoryId=java.net -Durl=http://download.java.net/maven/2/ -Dfile=robo-guice-0.4-20091121.174618-1.jar -DpomFile=robo-guice-0.4-20091121.174618-1.pom -DgroupId=robo-guice -DartifactId=robo-guice -Dversion=0.4-SNAPSHOT -Dpackaging=jar
but I think I'm barking up the wrong tree since it appears that the install plugin is used to copy locally built files into the local repository, rather than download remote artifacts into the local repository.
This is the artifact I'd like to install: http://download.java.net/maven/2/robo-guice/robo-guice/0.4-SNAPSHOT/
Is this possible using maven?
Since version 2.1 of the Maven Dependency Plugin, there is a dependency:get goal for this purpose. To make sure you are using the right version of the plugin, you'll need to use the "fully qualified name":
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
-DrepoUrl=http://download.java.net/maven/2/ \
-Dartifact=robo-guice:robo-guice:0.4-SNAPSHOT
Give them a trivial pom with these jars listed as dependencies and instructions to run:
mvn dependency:go-offline
This will pull the dependencies to the local repo.
A more direct solution is dependency:get, but it's a lot of arguments to type:
mvn dependency:get -DrepoUrl=something -Dartifact=group:artifact:version
As of version 2.4 of the Maven Dependency Plugin, you can also define a target destination for the artifact by using the -Ddest flag. It should point to a filename (not a directory) for the destination artifact. See the parameter page for additional parameters that can be used
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get \
-DremoteRepositories=http://download.java.net/maven/2 \
-Dartifact=robo-guice:robo-guice:0.4-SNAPSHOT \
-Ddest=c:\temp\robo-guice.jar