Maven打包带源码
打源码包
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
- 打包后的源代码和编译生成的文件放在一个
jar
文件里面,而不是单独的一个xxx-source.jar
Eclipse查看jar源码乱码问题
Window
=>Preferences
=>General
=>Content Types
=>Text
=>Java Source File
=>设置Default encoding
的值为UTF-8
General
=>Workspace
=>Text file encoding
的编码模式为Other:UTF-8
。
.end