mr.engineer
mr.engineer

Reputation: 197

Chaning default class name in Maven archetype:generate

Is there a way to set up default class name in Maven?

I'm creating the new project with this command:

mvn -B archetype:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=path.to.project \
  -DartifactId=ProjectName

I get this structure of files:

ProjectName
    |---src
    |     |--main
    |     |    |----java
    |     |           |----path
    |     |                 |-----to
    |     |                        |----project
    |     |                               |-------App.java
    |     | 
    |     |--test
    |         |----java
    |                |----path
    |                      |-----to
    |                             |----project
    |                                    |-------AppTest.java
    |---pom.xml

I want to create app with different default name. Let's say, to replace App.java with NewAppName.java and AppTest.java with NewAppNameTest.java.

Is there a way to modify my command to get desired outcome?

Upvotes: 2

Views: 2311

Answers (1)

Guo Song
Guo Song

Reputation: 352

No, you can't.

But you can write your own Archetypes, naming the default class file name: NewAppName.java in your project.

reference:

http://maven.apache.org/guides/mini/guide-creating-archetypes.html

Upvotes: 2

Related Questions