How to install Maven archetype from local JAR and POM, and also update local catalog - maven

I want to distribute a custom archetype JAR and POM, without deploying them to a Maven repository, so that someone can grab them and install in their local repository with something like a mvn install:install-file -Dfile <file> -DpomFile <pom>.
But if one just does:
mvn install:install-file -Dfile=./my-archetype-1.0.jar -DpomFile=./my-archetype-1.0.pom
the local catalog doesn't get updated.
Though there are similar questions like this, this and this, they left me missing a small step.
I'm not sure how to run the mvn archetype:update-local-catalog that they mention. Where's the pom.xml?

Simply run mvn -f <archetypePomFile> archetype:update-local-catalog doing a mvn -f pointing to the archetype pom.
So altogether it's:
Install archetype
mvn install:install-file -Dfile=./my-archetype-1.0.jar -DpomFile=./my-archetype-1.0.pom
Update local catalog
mvn -f my-archetype-1.0.pom archetype:update-local-catalog
Maybe that's obvious to others reading the doc but I spent enough time on this that I thought I'd write it up.

Related

Run tomcat project without pom.xml (like yum or apt-get)

For a presentation purpose and installation handbook i like to run a tomcat-project directly with only maven installed.
I googled around an found:
a way to download the dependency directly my mvn dependency:get
a way to start the war by mvn tomcat7:run
Is there any way to have a short shell-command who download the dependency from the server, compile and start it?
Actually i got this:
mvn dependency:get tomcat7:run
-DgroupId=XXXXX
-DartifactId=hasty-tumbleweed
-Dversion=0.9.2-SNAPSHOT
-DrepoUrl=file://C:/Users/woodcraft.xenther-vladic/.m2/repository
But mvn still try to find the plugin from the official maven repository.
Any Idea?
Are you maybe missing this:
Caveat: will always check the central repository defined in the super pom
From the little information here, you make it look as if you're distributing files already (the repository stuff) so why not provide a POM as well, opening you up to doing whatever nifty Maven stuff you desire. Then you can do:
mvn install -f <path to your POM>

How to register my maven archetype so that it gets listed as part of archetype:generate

How to register my maven archetype so that it gets listed as part of mvn archetype:generate call?
the mvn archetype:generate command lists the archetype defined in the catalog file from the maven central repository...
This catalog is meant to contains stable and reliable archetypes...
If your archetype will help us to save the world, you should create a JIRA and ask for them to register you project: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
Otherwise you can setup a local catalog that will be used to spread your project.
HIH
M.
you can install the archtype ( mvn install) into your local repository first and then it will be available for mvn archetype:generate command.
mvn archetype:generate -DarchetypeGroupId=gpid -DarchetypeArtifactId=archetype

mvn clean install, mvn install:install-file order?

I am learning maven and trying to understand the order of things. As I understand, mvn clean install builds the repository with the default jars, where install produces a .zip that I will need later.
I want to use my custom jars which I call mvn install:install-file, but when I run this before install, I get some cannot find symbol errors. I am assuming my custom jars (which don't contain these classes) overwrites some default jars? I can't find these classes anywhere on my filesystem, so I am assuming they are already packaged in 1 of the default jars. How can I get around this?
Also, which order should I do things? All I want is the final .zip, that includes the custom jars?
mvn install -- builds and packages the source code and copies ( installs ) the artifact to your local repository which is $USER_HOME/.m2/repository
It's hard to say what's happening there without looking at the command you typed in, and the error trace that you received. That said, install-file is to copy an artifact to your local repo at appropriate hierarchy. It's nothing more than that. The correct syntax would be:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
Usually, you just need to run install:install-file for all the custom dependencies once, and before you execute the mvn install.
If your custom jars have same coordinates -- artifactid, groupid, and version as some of the dependencies in your pom.xml and your custom jars do not have the classed that your source code uses -- well, you get the error.
refer: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
Regarding to the maven-install-plugin website they mention as the following: -
install:install-file: is mostly used to install an externally created artifact into the local repository, along with its POM. In that case the project information can be taken from an optionally specified pomFile, but can also be given using command line parameters.
This means the artifact should be created before using this command. If you would like to deploy your fresh compiled code to the local repository, please just use the mvn clean install.
Please look at the Introduction to the Build Lifecycle for further information about the sequence and lifecycle. I hope this may help.
Regards,
Charlee Ch.

Where can I get the NaturalDocs Maven plugin?

The maven configuration mentioned in the Usage section of the Natural Docs Maven Plugin site:
<groupId>org.codehaus.mojo.naturaldocs</groupId>
<artifactId>naturaldocs-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
However; I can't seem to find any version in any Maven repository including Maven Central or the Snapshot repo.
I was able to find what seems like the initial version attached to this Mojo plugin submission but it only includes source, and while it's nice to look at I don't wish to compile it for use myself.
Grab the source archive that you referenced and unzip it in a convenient spot.
From that folder, run:
mvn clean install
Assuming that runs without issue, run:
mvn install:install-file -Dpackaging=jar -Dfile=target\naturaldocs-maven-plugin-1.0-SNAPSHOT.jar -DgroupId=org.codehaus.mojo.naturaldocs -DartifactId=naturaldocs-maven-plugin -Dversion=1.0-SNAPSHOT
Assuming that runs fine, check the local deploy works as expected by including the pom reference in your project.
<dependency>
<groupId>org.codehaus.mojo.naturaldocs</groupId>
<artifactId>naturaldocs-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
If your project build without issue, then deploy it to your local Maven repo by running:
mvn deploy:deploy-file -Dpackaging=jar-Drepository=extNonFree -Durl=scpexe://maven.your-company.com/your-serverpath/maven/proximity/ext-non-free/storage -Dfile=target\naturaldocs-maven-plugin-1.0-SNAPSHOT.jar -DgroupId=org.codehaus.mojo.naturaldocs -DartifactId=naturaldocs-maven-plugin -Dversion=1.0-SNAPSHOT
Or have one of your local Maven admins deploy the pom and jar manually.
I hope that helps.

Is there any Apache Click maven archtype similar to Wicket's?

Is there any Apache Click maven archetype similar to Wicket's quick start? Similar to http://wicket.apache.org/start/quickstart.html
Basically what I need is a way to get started using Apache Click quickly using Maven.
Thanks in advance.
I never tried it myself, but this project provides a maven archetype for click. It doesn't look like they provide it in a public repository, so you will need to check the sources, compile&install it and than you'll be able to use it, e.g.:
$ svn checkout http://construtor.googlecode.com/svn/trunk/ construtor-read-only
$ cd construtor-read-only/maven-archetype-click/
$ mvn clean install
$ mvn archetype:generate
[...]
387: local -> maven-archetype-click (An archetype which generates a simplifed sample of the Apache Click Framework.)
[...]
For the benefit of future enquirers, there are instructions to achieve this here. However, the remote build did not work for me using Maven 3 nor did the local installation suggested without some modifications. This is what worked for me:
Download the archetype jar file
Install the archetype in the local maven 3 repo:
mvn install:install-file -DgroupId=com.google.constructor.archetypes -DartifactId=maven-archetype-click -Dversion=1.0 -Dpackaging=jar -Dfile=\maven-archetype-click-1.0.jar
Generate skeleton project:
mvn archetype:generate -DarchetypeGroupId=com.google.constructor.archetypes -DarchetypeArtifactId=maven-archetype-click -DarchetypeVersion=1.0 -DgroupId=com.test -DartifactId=clickprimer -DarchetypeCatalog=local
cd clickprimer
mvn clean package
mvn jetty:run

Resources