Maven 3 - Unable to find archetype - maven

I have created a customized archetype, customA-web-archetype. Within the project folder, customA-web-archetype , I ran mvn clean install archetype:update-local-catalog which was successful. Now when I run mvn archetype:generate -DarchetypeCatalog=local outside the folder to use the archetype, I am getting the following error:
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
Your filter doesn't match any archetype (hint: enter to return to initial list)
FYI- When I was setting up Maven, I moved the .m2 to a different directory rather than using the default home directory. I made the appropriate change to settings.xml so that it can find the .m2 in the updated directory structure.
I am not using any repo manager such as Nexus. Just a local m2 repo sitting on the same box as the archetype project.

To run the archetype command, you need to specify the groupId, artefactId and version of your archetype, as well as those of your future maven project.
You should try the following command, with your own parameters:
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=yourArchetypeGroupId -DarchetypeArtifactId=yourArchetypeArtifactId -DarchetypeVersion=yourArchetypeVersion -DgroupId=projectGroupId -DartifactId=projectArtifactId -DinteractiveMode=false

After upgrading from Maven 2 to 3 we found the same problem. The fix was to change the version of the archetype-packaging and maven-archetype-plugin from 2.2 to 3.0.0 in the archetype pom.
I looks like maven moved the location of it's archetype repository file from ~/.m2 to ~/.m2/repositories which is why generate wasn't finding it.
One strange behavior I'm still seeing is that if I just do
mvn archetype:generate
it doesn't show my local archetypes, however if I do a
mvn archetype:generate -DarchetypeCatalog=local
it shows up. Hope this helps.

Have you tried crawling the repo to create a catalog? Perhaps it's missing / broken? Archetype plugin has crawl goal, which parses the repo and creates catalog.xml.
mvn archetype:help
[... snip ...]
archetype:crawl
Crawl a Maven repository (filesystem, not HTTP) and creates a catalog file.

Related

How can I specify the directory where to create the project for archetype:generate?

I am using mvn archetype:generate -B ... to generate a maven project.
It places the generated project in the current working directory.
Can this be customized to place the generated project in a directory I specify? I don't see any options to do so in the command line --help menu.
You cannot specify a directory for archetype:generate, this plugin always targets the current working directory.
The Maven Archetype docs suggest using the basedir parameter. Something like this perhaps:
mvn archetype:generate
-DgroupId=foo
-DartifactId=bar
-Dbasedir=/some/other/directory
But, unfortuntately that doesn't work, even with that parameter specified the archetype is generated into the current working directory. Looking at the Maven Archetype JIRA I can see that there is an open issue for this:
https://issues.apache.org/jira/browse/ARCHETYPE-311
This issue has been open since April 2010 and it has been raised against version 2.2.0 of the archetype plugin and I have just verified that this issue still exists with in latest version of the archetype plugin, the following command completed but created bar in the current working directory rather than in /some/other/path ...
mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
-DgroupId=bar
-DartifactId=foo
-Dbasedir=/some/other/directory
So, if you want to use archetype:generate and you want the generated project to exist somewhere else then I think you might have to write a simple script which ...
Invokes the plugin
Moves the created directory to your desired location once the plugin has finished running
-Dbasedir doesn't work.
You could specify output directory by passing -DoutputDirectory=/some/other/directory
Here's the documentation
https://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html

Project creation based on custom archetype leaves out folders

I created my own maven archetype in my company's maven nexus.
The archetype jar file has all the necessary folders and pom.xml in the archetype-resources folder
But when I create a project based off of the archetype, the folders all get left out and only the pom.xml remains.
How can I fix this issue?
Thanks
Just as a note, I tried to create the archetype jar in several ways:
mvn archetype:create-from-project
mvn install
mvn deploy
mvn clean compile assembly:single
I still get the same issue

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

maven-bundle-plugin: The defined artifact is not an archetype

I configured the "maven-bundle-plugin" from Apache Felix as a Maven Archetype in Eclipse (since it was missing), but when I try to create a new Maven project with it, I get as error:
Unable to create project from archetype [org.apache.felix:
maven-bundle-plugin:2.3.5 -> ]
The defined artifact is not an archetype
I then tried the same procedure with ops4j Pax (which is pre-configured in Eclipse), which seems to be something similar, and it worked, so I think I'm doing it right and the problem is with "maven-bundle-plugin".
What does the error message mean, and what can I do to fix it, or am I somehow getting this all wrong?
[EDIT] While I can create the project with ops4j Pax, I afterward get:
Project build error: Unknown packaging: bundle
which as apparently been fixed in 2009! So this obviously doesn't work either.
I finally had success with the following procedure:
cd workspace
mvn org.ops4j:maven-pax-plugin:create-bundle -Dpackage=demo.service
-DbundleGroupId=demo.service -DbundleName=demo.service-bundle
-Dversion=0.1
cd demo.service-bundle
mvn org.ops4j:maven-pax-plugin:eclipse
# Import project as Eclipse project
# (I haven't try to import it as maven project)
And btw, it took me about ages to work out why this doesn't work in a Windows batch file: that is because mvn is itself a batch file, and so you have to use "call".

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