有時,我們需要將源代碼與編譯的Java字節(jié)一起打包到一個jar文件中碼。 例如,Eclipse IDE可能需要源代碼的jar文件來顯示源代碼。
它對于使用我們部署的項(xiàng)目進(jìn)行源代碼級調(diào)試的開發(fā)人員也很有用。
“maven-source"插件可以打包源代碼并與我們的項(xiàng)目一起部署。
在“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>
發(fā)出“mvn install"打包并將我們的項(xiàng)目部署到本地存儲庫。
c:\mvn_test\xmlFileEditor>mvn install
更多建議: