Dynamic file name in the Maven archetype

I have a problem with Maven. I tried to create an archetype, but now I can not put the source file in the ${groupId}/${artifactId} directory. If I try to create a project from this archetype, the file will be stored implicitly in the ${groupId} . Maven seems to assume that the group identifier is the name of the package. But I use ${groupId}/${artifactId} as the package name, so I need the source file stored in the ${groupId}/${artifactId} directory. I saw a solution: put the file in the __artifactId__ directory. Double underscore should define a variable. However, this has no effect. The variable seems empty, but is used successfully in the package name inside the source file.

Is there any idea of โ€‹โ€‹enybody, what trick should have been done using double underscore in the file name?

+4
source share
1 answer

When you create the archetype of your project as follows: mvn archetype:create-from-project -Dinteractive Install the package - explicitly at the root of the project.

Then you create a project of this archetype, enter your root package $ {groupId}. $ {artifactId} explicitly. example: mvn archetype: generate -DarchetypeGroupId = com.test -DarchetypeArtifactId = my_archetype -DgroupId = com.test -DartifactId = app -Dpackage = com.test.app -Dversion = 1.0-SNAPHOT

In this case, $ {groupId} = com.test, $ {artifactId} = application and target package = com.test.app

-5
source

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


All Articles