java要多思考下

成长^_^

   ::  :: 新随笔 ::  ::  :: 管理 ::
  33 随笔 :: 0 文章 :: 19 评论 :: 0 Trackbacks
关于jenkins的使用及自动化配置步骤,在本博上篇已经有所介绍,这里只列下如何使用maven的强大插件assembly

1、假设静态资源的目录结构为:
            static/js/xxxx
            static/css/xxxx
            static/images/xxxx

            static/configure/xxx.js
            static/pom.xml
            static/assembly.xml
2、配置pom.xml

 1             <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 3                 <modelVersion>4.0.0</modelVersion>
 4                 <groupId>com.test</groupId>
 5                 <artifactId>static</artifactId>
 6                 <packaging>pom</packaging>
 7                 <version>1.0</version>
 8 
 9                 <properties>
10                     <fileName>static</fileName>
11                     <SettingJs>configure/xxx.js</SettingJs>
12                 </properties>
13 
14                 <build>
15                     <finalName>${fileName}</finalName>
16 
17                     <plugins>
18                         <plugin>
19                             <groupId>org.apache.maven.plugins</groupId>
20                             <artifactId>maven-antrun-plugin</artifactId>
21                             <version>1.6</version>
22                             <executions>
23                                 <execution>
24                                     <id>compile</id>
25                                     <phase>compile</phase>
26                                     <configuration>
27                                         <target>
28                                             <copy file="${SettingJs}" tofile="js/xxx.js"
29                                                 overwrite="true" />
30                                         </target>
31                                     </configuration>
32                                     <goals>
33                                         <goal>run</goal>
34                                     </goals>
35                                 </execution>
36                             </executions>
37                         </plugin>
38 
39                         <plugin>
40                             <groupId>org.apache.maven.plugins</groupId>
41                             <artifactId>maven-assembly-plugin</artifactId>
42                             <version>2.2.1</version>
43                             <configuration>
44                                 <descriptors>
45                                     <descriptor>assembly.xml</descriptor>
46                                 </descriptors>
47                             </configuration>
48                             <executions>
49                                 <execution>
50                                     <id>make-assembly</id>
51                                     <phase>package</phase>
52                                     <goals>
53                                         <goal>single</goal>
54                                     </goals>
55                                 </execution>
56                             </executions>
57                         </plugin>
58                     </plugins>
59                 </build>
60             </project>

3、配置assembly.xml

 1 <assembly
 2                 xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
 3                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4                 xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
 5                 <id>all</id>
 6                 <formats>
 7                     <format>zip</format>
 8                 </formats>
 9 
10                 <fileSets>
11                     <fileSet>
12                         <directory>js</directory>
13                         <useDefaultExcludes>true</useDefaultExcludes>
14                     </fileSet>
15                     <fileSet>
16                         <directory>images</directory>
17                         <useDefaultExcludes>true</useDefaultExcludes>
18                     </fileSet>
19                     <fileSet>
20                         <directory>css</directory>
21                         <useDefaultExcludes>true</useDefaultExcludes>
22                     </fileSet>
23                 </fileSets>
24             </assembly>

4、jenkins中,当构建任务结束后,将生成static-all.zip文件,配置自动上传至目标服务器,最后使用命令unzip -o static-all.zip解压覆盖即可

 技术文章收藏站点
posted on 2012-11-14 18:55 java要多思考下 阅读(7406) 评论(0)  编辑  收藏 所属分类: 研发管理系统运维

只有注册用户登录后才能发表评论。


网站导航: