Maven生成源Jar
2018-01-09 19:18 更新
Maven教程 - Maven生成源Jar
有时,我们需要将源代码与编译的Java字节一起打包到一个jar文件中码。 例如,Eclipse IDE可能需要源代码的jar文件来显示源代码。
它对于使用我们部署的项目进行源代码级调试的开发人员也很有用。
“maven-source"插件可以打包源代码并与我们的项目一起部署。
Maven源插件
在“pom.xml"文件中添加“maven-source"插件。
<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>com.java2s.ide</groupId>
<artifactId>xmlFileEditor</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>xmlFileEditor</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
发出“mvn install"打包并将我们的项目部署到本地存储库。
c:\mvn_test\xmlFileEditor>mvn install
以上内容是否对您有帮助:

免费 AI IDE


更多建议: