Installing current version of DWR via Maven - maven

I checked out current SVN Snapshot of DWR (3.0.0-rc3-SNAPSHOT) and I am unable to mvn install it - the pom.xml seem to be configured not for such command. What is the correct way of installing DWR into maven repo?
I also tried copying files from https://oss.sonatype.org/content/repositories/snapshots/org/directwebremoting/dwr/3.0.0-rc3-SNAPSHOT/ and mvn installing them as well. This way obviously does not work either. How can it be installed from here? I don't want to link to the snapshot directory directory from my pom.xml as I don't want to get unexpected results when new snapshot is introduced.

I'm not sure if I get you correctly, but you can always download the JAR and install it locally using Maven. Something like this:
mvn install:install-file -Dfile=dwr-3.0.0-rc3-20130514.180049-1.jar -DgroupId=org.directwebremoting -DartifactId=dwr -Dversion=3.0.0-rc3-SNAPSHOT -Dpackaging=jar
more on the Maven info here:
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
EDIT:
I managed to install it from source as well by do SVN checkout:
svn co https://svn.directwebremoting.org/dwr/trunk/
My first attempt to build it failed because I was using Maven 2.x. Seems like DWR is using Maven enforcer plugin to enforce certain Maven version. I didn't check which version is really required but by updating my Maven to Maven3 I managed to install it.

Related

How to update maven package after commit/pull-request

I am using a package https://github.com/dhatim/fastexcel, resently there was a commit in their repo, but the version had not been changed in Readme(description) of package in git hub, how can I update the package using maven?
I tried to run mvn release:update-versions, but I get this error
Then I run mvn release:update-versions -X
This is my pom.xml
The git repo is not equal the maven lib. You download maven libraries from the offical maven repository. The maintainer of the library needs to upload his artifact to the central repository when he builds a new release after that you can use this.
To see which version is usable you can use a maven search website like https://search.maven.org.
The dependency org.dhatim:fastexcel has a version 0.9.4 (same as the github release).
So it seems the developer already uploaded it but did not correct his Readme in the repository. So you can just use 0.9.4 in your pom.xml.
So always check the maven search site and if something is missing you can always add an issue to github to ask the developer uploading it.
There are also this more or less recommended possibilites to get library as a workaround:
Checkout and build the project by your self and add the jar file to:
something like nexus as own repository hosting (a organization normally has a maven proxy which could be used)
add it to the pom.xml as system scope dependency where the jar must be located on your system
use mvn install on the fastexcel project and change the version in your pom.xml to 0-SNAPSHOT

Add Archtypes to Eclipse

I am new to MAVEN and restful services. I have MAVEN installed it correctly and set the variables. I was creating a webservice using the jersey-quickstart-webapp but found it did not appeared in the list of Archetypes.
I tried to add it using using ADD Archetypes option. After the entering the details
GroupId: org.glassfish.jersey.archetypes
ArtifactId: jersey-quickstart-webapp
Version : 2.16 // version is correct??
I get following error please help.
<b>
org.eclipse.core.runtime.CoreException: Could not resolve artifact
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.16</b>
I don't have a ready explanation as to why the Eclipse archetype plugin was giving you this error, since 2.16 is a valid version of jersey-quickstart-webapp. However, I would recommend that you try manually executing the following command from a command prompt:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false
-DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example
-DarchetypeVersion=2.19
Make sure that you first delete the jersey-quickstart-webapp folder, if it exists, from your Maven .m2 directory. This may be necessary to avoid from something getting corrupted during the archetype install.
Here is a link to the official documentation for creating a Jersey EE application from a Maven archetype.

Cannot get the latest version of maven plugin

I am new to maven, I have write my own maven plugin with the pom file
<groupId>com.xxx.api</groupId>
<artifactId>xxx-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
then, in my IDE (intellij) I used clean install to install my maven plugin
and in the main project, my maven plugin works fine.
However, when I modify my maven plugin by adding parameter to my mojo and "mvn clean install" ,
(the groupId,artifactId,version keep the same) it supposed to be the latest version.
However, in the main project, when I try to use the latest maven plugin, I always get the old version
i.e I cannot configure the parameter that I just add to my maven plugin (because it is not exist!)
I have try to delete the maven plugin in my .m2 repo, before I install the latest version of my maven plugin, it still not work.
Any solution that I can get the latest version of my maven plugin by keeping the same
(groupId, artifactId,version)?
thanks,
Zach
Check how the using project is configured. I guess it has its own lib/classes folder. I would suspect that your project has a copy of the older version of the plugin in its lib folder. If so, that is where it is getting the old version. Clean it out from there, i.e. you need to clean the using project.

Maven Repository

I have downloaded all artifacts in maven repository. Now I copied the repository folder content to other computer running maven. I have to access this new repository for maven commands but it is trying to connect to net for downloading artifacts required. What should I do??
Is there any way of using such repository created manually??
Are you using snapshot versions of your dependencies? If so, Maven might still try to connect to a remote repository to check if there is a new version available. However, you can avoid this by using -o (=offline), like this:
mvn -o <your_command>
Did you set the correct path to the maven repository in your settings.xml file?
This is happening because you might have a different version of Maven on your new machine and thus, it will try to install all the new compatible plugins while you try to build it. So there is no way to get around it except for using exactly the same maven version and same settings

How do I find the latest version of an artifact from a maven repository

As part of an automated deployment I need a script to download the latest version of an artifact from our internal repository.
Ideally this script will be with ant or a unix shell script.
So for example:
I have myArtifact.war and it has versions 1.0 , 1.1 and 2.0 - I need the script given the correct group id and artifact id to retrieve version 2.0 from our maven repository (currently using artifactory).
Is there any easy way to do this?
You can use the Maven Dependency Plugin goal get together with LATEST as version for your artifact:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get
-DremoteRepositories=<URL_to_your_maven_repo>
-Dartifact=<group_id>:<artifact_id>:LATEST
-Dpackaging=jar
-Ddest=<target_dir>/<artifact_name>.jar
You can parse the maven-metadata.xml to see what versions are available, and which version is the "release" version. See this answer about plugin versions for more details.
If you are using Nexus, you can use the REST API to query the repository. You can also use the REST client API to simplify your processing.
To update the release version, activate the release-profile in the Maven super POM when you do mvn deploy. You can do this by adding -Prelease-profile or -DperformRelease=true to the command line.
The profile is activate by default in the maven-release-plugin's perform goal. It is controlled by the useReleaseProfile property. See the release-perform goal's documentation for more details.

Resources