Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ask for maven archetype properties with defaults

I'm putting together a maven archetype that has a bunch of custom properties that are used to filter the various archetype resources. I have these specified with defaults in the archetype-metadata.xml e.g.

<requiredProperties>
  <requiredProperty key="application-name">
    <defaultValue>Some Application</defaultValue>
  </requiredProperty>>  
</requiredProperties>

However when I try to create a project with the archetype, it does not allow me to change these interactively. For instance, it asks for the version with default as follows

Define value for property 'version': 1.0-SNAPSHOT: 

allowing a version to be entered, but defaulting to 1.0-SNAPSHOT if nothing is entered. For my custom properties, it merely displays them prior to creating the new project

[INFO] Using property: application-name = Some Application

If I omit the default value from the archetype-metadata.xml then it will prompt me for a value, but there is no default.

Is it possible to supply a default and still get prompted?

like image 961
sgargan Avatar asked Oct 09 '10 00:10

sgargan


People also ask

What is default maven archetype?

the default archetype number now is 1092 1092: remote -> org. apache. maven. archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)

How do I find my maven archetype?

The archetype descriptor is a file called archetype-metadata. xml which must be located in the src/main/resources/META-INF/maven/ directory.

How do you know the which archetype an existing maven project is built on?

Archetype configurationYou can see the packaging maven-archetype . You can customize build of your archetype here as with any other pom. However, there is another pom. xml file located under src\main\resources\archetype-resources which is the pom file of the generated project.

Where are maven archetypes stored?

The metadata about an archetype is stored in the archetype-metadata. xml file located in the directory META-INF/maven of its JAR file, see the reference documentation. The metadata file stores the additional properties, with corresponding default values. It also stores the project's generated files in filesets.


2 Answers

In short, no, it isn't possible. There's a JIRA issue on this. If it is a problem for you, you may want to vote for it.

like image 82
Ed Staub Avatar answered Sep 21 '22 20:09

Ed Staub


please look for a final question to commit the settings. In my case there is a final question:

:
Confirm properties configuration:
groupId: ....
 Y: :

If i enter n then all properties will be re-ask interactive with my defaults from archetype-metadata.xml.

Here is my console part:

Choose archetype:
1: file:///C:\Aktentasche\_daten\m3 -> maven-dsl-project-archet...
Choose a number: : 1
Downloading: file:///C:\Aktentasche\_daten\m3/net/sf/maven/plug...
data.xml
[INFO] Using property: groupId = net.sf.maven.plugins
[INFO] Using property: artifactId = dslexample
[INFO] Using property: version = 1.0.0-SNAPSHOT
[INFO] Using property: package = net.sf.maven.plugins
[INFO] Using property: eclipse_platform = helios
[INFO] Using property: tycho_version = 0.8.0
Confirm properties configuration:
groupId: net.sf.maven.plugins
artifactId: dslexample
version: 1.0.0-SNAPSHOT
package: net.sf.maven.plugins
eclipse_platform: helios
tycho_version: 0.8.0
 Y: :

Here i must enter n for interactive dialog with defaults.

like image 44
Huluvu424242 Avatar answered Sep 21 '22 20:09

Huluvu424242