有没有办法使用Maven构建Java项目而没有所有不必要的目录?
https://spring.io/guides/gs/maven/
看起来像Maven期待的那样
src/
main/
java/
package1/
package2/
package3/
packageX/
Run Code Online (Sandbox Code Playgroud)
我想创建一个带有pom.xml文件的Maven项目,它看起来更像:
src/
package1/
package2/
package3/
packageX/
Run Code Online (Sandbox Code Playgroud)
这可能吗?
这是我正在使用的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-maven</artifactId>
<packaging>jar</packaging>
<version>0.1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>hello.HelloWorld</mainClass>
<arguments>
<argument>argument1</argument>
</arguments>
<systemProperties>
<systemProperty>
<key>myproperty</key>
<value>myvalue</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>hello.HelloWorld</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我建议你遵循这个src/main/java结构,因为它提供了好处(看看这里),但是如果你因为任何其他原因src(或任何文件夹)必须更改文件夹结构,那么你可以通过sourceDirectory在你的指定中指定pom.xml如下所示:
<build>
<sourceDirectory>src</sourceDirectory>
</build>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1548 次 |
| 最近记录: |