maven 打包 dubbo provider jar
? ?build脚本
?
? 项目结构需要注意 spring 放到 rescource的 META-INF/spring下
?

?
?
?
<build>
? ? ? ? <finalName>x1-service-provider</finalName>
? ? ? ? <sourceDirectory>src/main/java</sourceDirectory>
?
? ? ? ? <resources>
? ? ? ? ? ? <resource>
? ? ? ? ? ? ? ? <targetPath>${project.build.directory}/</targetPath>
? ? ? ? ? ? ? ? <directory>src/main/resources</directory>
? ? ? ? ? ? ? ? <filtering>true</filtering>
? ? ? ? ? ? ? ? <includes>
? ? ? ? ? ? ? ? ? ? <include>**/*.xml</include>
? ? ? ? ? ? ? ? </includes>
? ? ? ? ? ? ? ? <excludes>
? ? ? ? ? ? ? ? ? ? <exclude>**/*.properties</exclude>
? ? ? ? ? ? ? ? </excludes>
? ? ? ? ? ? </resource>
? ? ? ? </resources>
?
? ? ? ? <plugins>
? ? ? ? ? ? <!-- 设置源文件编码方式 -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-compiler-plugin</artifactId>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <source>1.6</source>
? ? ? ? ? ? ? ? ? ? <target>1.6</target>
? ? ? ? ? ? ? ? ? ? <encoding>UTF-8</encoding>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
? ? ? ? ? ? <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-jar-plugin</artifactId>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <classesDirectory>target/classes/</classesDirectory>
? ? ? ? ? ? ? ? ? ? <excludes>
? ? ? ? ? ? ? ? ? ? ? ? <exclude>**/*.properties</exclude>
? ? ? ? ? ? ? ? ? ? </excludes>
? ? ? ? ? ? ? ? ? ? <archive>
? ? ? ? ? ? ? ? ? ? ? ? <addMavenDescriptor>false</addMavenDescriptor>
? ? ? ? ? ? ? ? ? ? </archive>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
? ? ? ? ? ? <!-- 拷贝依赖的jar包到lib目录 -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-dependency-plugin</artifactId>
? ? ? ? ? ? ? ? <executions>
? ? ? ? ? ? ? ? ? ? <execution>
? ? ? ? ? ? ? ? ? ? ? ? <id>copy</id>
? ? ? ? ? ? ? ? ? ? ? ? <phase>package</phase>
? ? ? ? ? ? ? ? ? ? ? ? <goals>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <goal>copy-dependencies</goal>
? ? ? ? ? ? ? ? ? ? ? ? </goals>
? ? ? ? ? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <outputDirectory>
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ${project.build.directory}/lib
? ? ? ? ? ? ? ? ? ? ? ? ? ? </outputDirectory>
? ? ? ? ? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? ? ? ? ? </execution>
? ? ? ? ? ? ? ? </executions>
? ? ? ? ? ? </plugin>
? ? ? ? ? ? <!-- 解决资源文件的编码问题 -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <groupId>org.apache.maven.plugins</groupId>
? ? ? ? ? ? ? ? <artifactId>maven-resources-plugin</artifactId>
? ? ? ? ? ? ? ? <version>2.3</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <encoding>UTF-8</encoding>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? </plugin>
? ? ? ? ? ? <!-- 打包source文件为jar文件 -->
? ? ? ? ? ? <plugin>
? ? ? ? ? ? ? ? <artifactId>maven-source-plugin</artifactId>
? ? ? ? ? ? ? ? <version>2.1</version>
? ? ? ? ? ? ? ? <configuration>
? ? ? ? ? ? ? ? ? ? <attach>true</attach>
? ? ? ? ? ? ? ? </configuration>
? ? ? ? ? ? ? ? <executions>
? ? ? ? ? ? ? ? ? ? <execution>
? ? ? ? ? ? ? ? ? ? ? ? <phase>compile</phase>
? ? ? ? ? ? ? ? ? ? ? ? <goals>
? ? ? ? ? ? ? ? ? ? ? ? ? ? <goal>jar</goal>
? ? ? ? ? ? ? ? ? ? ? ? </goals>
? ? ? ? ? ? ? ? ? ? </execution>
? ? ? ? ? ? ? ? </executions>
? ? ? ? ? ? </plugin>
? ? ? ? </plugins>
? ? </build>