Maven archetype from project - how to save package names?

I am trying to capture my project and create an Archetype from it through:

archetype:create-from-project

The fact is that in my project there is a package structure src / main / java com.sample.app, but the archetype should have it as the user wants it when it generates the project from the archetype, but this is impossible, I suppose. It does not seem to capture groupId and artifactId and generates archetype-resources/src/main/javabased on this input.

Anyway, why is there this argument, I suppose: packageName

mvn archetype:create-from-project -DpackageName=com.sample.app

But it does not work, and there is still archetype-resources/src/main/java/org/sample/app..

+3
source share
1 answer

The target create-from-projectusually automatically determines the name of the base package and replaces it, so in the end you will get \templateproject\target\generated-sources\archetype\src\main\resources\archetype-resources\src\test\java\Foo.javawith the package declaration${package}

- hello-world, , . , , archetype:generate, .

+4

Source: https://habr.com/ru/post/1783471/


All Articles