强制 Maven 不生成 target/classes 目录
Force Maven not to generate target/classes directory
我尝试使用 Checksum Maven Plugin 为由 Assembly 插件组装的分发生成校验和文件。不幸的是,它还尝试计算 target/classes
目录的校验和,当然失败了,因为它是空的。
除了破解之外,还有什么方法可以抑制 target/classes
和 target/test-classes
的创建?
Checksum Maven 插件的当前配置如下:
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>artifacts</goal>
</goals>
</execution>
</executions>
<configuration>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
<algorithm>SHA-256</algorithm>
</algorithms>
</configuration>
</plugin>
使用 files 目标。
上面的示例将为目录目标中的所有文件生成校验和(由 属性 ${project.build.directory} 表示)。
到运行,使用目标net.nicoulaj.maven.plugins:checksum-maven-plugin:1.5:files
我用一个带有装配工件的 Maven 项目进行了测试。我可以从你的问题中重现问题。我也测试了这个解决方案并且它有效!
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>files</goal>
</goals>
</execution>
</executions>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
</fileSet>
</fileSets>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
<algorithm>SHA-256</algorithm>
</algorithms>
</configuration>
</plugin>
我尝试使用 Checksum Maven Plugin 为由 Assembly 插件组装的分发生成校验和文件。不幸的是,它还尝试计算 target/classes
目录的校验和,当然失败了,因为它是空的。
除了破解之外,还有什么方法可以抑制 target/classes
和 target/test-classes
的创建?
Checksum Maven 插件的当前配置如下:
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>artifacts</goal>
</goals>
</execution>
</executions>
<configuration>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
<algorithm>SHA-256</algorithm>
</algorithms>
</configuration>
</plugin>
使用 files 目标。
上面的示例将为目录目标中的所有文件生成校验和(由 属性 ${project.build.directory} 表示)。
到运行,使用目标net.nicoulaj.maven.plugins:checksum-maven-plugin:1.5:files
我用一个带有装配工件的 Maven 项目进行了测试。我可以从你的问题中重现问题。我也测试了这个解决方案并且它有效!
<plugin>
<groupId>net.nicoulaj.maven.plugins</groupId>
<artifactId>checksum-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>files</goal>
</goals>
</execution>
</executions>
<configuration>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
</fileSet>
</fileSets>
<algorithms>
<algorithm>MD5</algorithm>
<algorithm>SHA-1</algorithm>
<algorithm>SHA-256</algorithm>
</algorithms>
</configuration>
</plugin>