Maven archetype:generate 强制 groupId 作为包结构
Maven archetype:generate forcing groupId as package structure
我正在尝试创建一个原型来生成一个 Maven 项目,其中包含一些将在文件中使用的属性以及文件名和目录结构。
我运行遇到的问题是如何控制包的目录结构?到目前为止,无论我尝试过什么,我指定的 groupId
(这是 archetype:generate
中的强制参数)都会强制自己作为包目录结构。如果我尝试在我的 archetype-resources
目录设置或 Java 文件本身的包名称中使用不同的东西,我最终会得到我在那里指定的任何内容,以及 groupId
.
实际上,我希望我的项目结构与我的 groupId
不同,但原型生成似乎将 groupId
强制到包结构中。
有办法阻止吗?
如果我使用以下命令:
archetype:generate -DarchetypeGroupId=archetype.test -DarchetypeArtifactId=archetype-test -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.example.test.project-DartifactId=my.test.project.artifact -Dversion=1.0.0-SNAPSHOT
与以下 fileset
:
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/MyClass.java</include>
</includes>
</fileSet>
我的 Java 文件位于:
src/main/java/com/example/test/project/MyClass.java.
我仍然想要相同的 groupId
,但我希望我的 class 位于单独的目录中,例如:
src/main/java/com/different/project/MyClass.java
见Create a Project from an Archetype – Batch mode:
It is possible to call the Archetype Plugin to generate a project in batch mode (to get rid of the prompting). This is achieved by providing the Archetype Plugin with all the needed values as system properties.
...
package
specifies the package for the sources of the generated project
...
长话短说,将以下内容添加到您的命令行:
-Dpackage=com.different.project
我正在尝试创建一个原型来生成一个 Maven 项目,其中包含一些将在文件中使用的属性以及文件名和目录结构。
我运行遇到的问题是如何控制包的目录结构?到目前为止,无论我尝试过什么,我指定的 groupId
(这是 archetype:generate
中的强制参数)都会强制自己作为包目录结构。如果我尝试在我的 archetype-resources
目录设置或 Java 文件本身的包名称中使用不同的东西,我最终会得到我在那里指定的任何内容,以及 groupId
.
实际上,我希望我的项目结构与我的 groupId
不同,但原型生成似乎将 groupId
强制到包结构中。
有办法阻止吗?
如果我使用以下命令:
archetype:generate -DarchetypeGroupId=archetype.test -DarchetypeArtifactId=archetype-test -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.example.test.project-DartifactId=my.test.project.artifact -Dversion=1.0.0-SNAPSHOT
与以下 fileset
:
<fileSet filtered="true" packaged="true">
<directory>src/main/java</directory>
<includes>
<include>**/MyClass.java</include>
</includes>
</fileSet>
我的 Java 文件位于:
src/main/java/com/example/test/project/MyClass.java.
我仍然想要相同的 groupId
,但我希望我的 class 位于单独的目录中,例如:
src/main/java/com/different/project/MyClass.java
见Create a Project from an Archetype – Batch mode:
It is possible to call the Archetype Plugin to generate a project in batch mode (to get rid of the prompting). This is achieved by providing the Archetype Plugin with all the needed values as system properties.
...
package
specifies the package for the sources of the generated project...
长话短说,将以下内容添加到您的命令行:
-Dpackage=com.different.project