Chinaunix首页 | 论坛 | 博客
  • 博客访问: 622595
  • 博文数量: 149
  • 博客积分: 3901
  • 博客等级: 中校
  • 技术积分: 1558
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-16 14:33
文章分类

全部博文(149)

文章存档

2014年(2)

2013年(10)

2012年(32)

2011年(21)

2010年(84)

分类: 架构设计与优化

2014-01-06 21:03:15


mvn archetype:create -DgroupId=my.mvn_rpm -DartifactId=study

cd study/


直接上 pom.xml

点击(此处)折叠或打开

  1. <project xmlns="" xmlns:xsi=""
  2.   xsi:schemaLocation=" ">
  3.   <modelVersion>4.0.0</modelVersion>

  4.   <groupId>my.mvn_rpm</groupId>
  5.   <artifactId>study</artifactId>
  6.   <version>1.0-SNAPSHOT</version>
  7.   <packaging>jar</packaging>

  8.   <name>study</name>
  9.   <url>http://maven.apache.org</url>

  10.   <properties>
  11.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  12.   </properties>

  13.   <dependencies>
  14.     <dependency>
  15.       <groupId>junit</groupId>
  16.       <artifactId>junit</artifactId>
  17.       <version>3.8.1</version>
  18.       <scope>test</scope>
  19.     </dependency>
  20.     <dependency>
  21.       <groupId>javax.servlet</groupId>
  22.       <artifactId>servlet-api</artifactId>
  23.       <version>2.4</version>
  24.       <scope>provided</scope>
  25.     </dependency>
  26.   </dependencies>



  27.     <build>
  28.         <plugins>

  29.          
  30.             <plugin>
  31.                 <groupId>org.apache.maven.plugins</groupId>
  32.                 <artifactId>maven-compiler-plugin</artifactId>
  33.                 <version>2.3.2</version>
  34.                 <configuration>
  35.                     <source>1.6</source>
  36.                     <target>1.6</target>
  37.                     <encoding>UTF-8</encoding>
  38.                 </configuration>
  39.             </plugin>

  40.             <plugin>
  41.                 <groupId>org.apache.maven.plugins</groupId>
  42.                 <artifactId>maven-jar-plugin</artifactId>
  43.                 <configuration>
  44.                 <archive>
  45.                 <manifest>
  46.                   <addClasspath>true</addClasspath>
  47.                   <classpathPrefix>lib/</classpathPrefix>
  48.                   <mainClass>my.mvn_rpm.App</mainClass> <!--入口类名 -->
  49.                 </manifest>
  50.                 </archive>
  51.                 </configuration>
  52.             </plugin>

  53.             <!-- 拷贝所以依赖存放位置 -->
  54.             <plugin>
  55.                 <groupId>org.apache.maven.plugins</groupId>
  56.                 <artifactId>maven-dependency-plugin</artifactId>
  57.                 <executions>
  58.                 <execution>
  59.                 <id>copy</id>
  60.                 <phase>package</phase>
  61.                 <goals>
  62.                     <goal>copy-dependencies</goal>
  63.                 </goals>
  64.                 <configuration>
  65.                 <outputDirectory>${project.build.directory}/lib</outputDirectory>
  66.                 </configuration>
  67.                 </execution>
  68.                 </executions>
  69.             </plugin>


  70.             <plugin>
  71.                 <groupId>org.codehaus.mojo</groupId>
  72.                 <artifactId>rpm-maven-plugin</artifactId>
  73.                 <version>2.1-alpha-3</version>
  74.                 <executions>
  75.                     <execution>
  76.                         <phase>install</phase>
  77.                         <id>generate-rpm</id>
  78.                         <goals>
  79.                             <goal>rpm</goal>
  80.                         </goals>
  81.                     </execution>
  82.                 </executions>
  83.                 <configuration>
  84.                     <copyright>2005, SWWDC</copyright>
  85.                     <distribution>Trash 2005</distribution>
  86.                     <group>Application/Collectors</group>
  87.                     <!--icon>src/main/resources/icon.gif</icon-->
  88.                     <packager>SWWDC</packager>
  89.                     <prefix>/usr/local</prefix>
  90.                     <changelogFile>src/changelog</changelogFile>
  91.                     <defineStatements>
  92.                        <defineStatement>_unpackaged_files_terminate 0</defineStatement>
  93.                     </defineStatements>

  94.                     <mappings>
  95.                         <mapping>
  96.                             <!-- classes 注入到指定目录 -->
  97.                             <directory>/usr/local/bin/mvn_rpm</directory>
  98.                             <filemode>440</filemode>
  99.                             <username>root</username>
  100.                             <groupname>root</groupname>
  101.                             <sources>
  102.                                 <source>
  103.                                     <location>target/classes</location>
  104.                                 </source>
  105.                             </sources>
  106.                         </mapping>

  107.                         <!-- lib 包依赖 -->
  108.                         <mapping>
  109.                             <directory>/usr/local/lib/mvn_rpm</directory>
  110.                             <filemode>750</filemode>
  111.                             <username>root</username>
  112.                             <groupname>root</groupname>
  113.                             <sources>
  114.                                 <source>
  115.                                     <location>${project.build.directory}/lib</location>
  116.                                 </source>
  117.                             </sources>
  118.                         </mapping>

  119.                         <mapping>
  120.                             <!-- 启动命令 -->
  121.                             <directory>/usr/local/bin</directory>
  122.                             <filemode>750</filemode>
  123.                             <username>root</username>
  124.                             <groupname>root</groupname>
  125.                             <sources>
  126.                                 <source>
  127.                                     <location>src/main/bin/mvn_rpm.sh</location>
  128.                                 </source>
  129.                                 <softlinkSource>
  130.                                     <location>/usr/local/bin/mvn_rpm</location>
  131.                                     <destination>mvn_rpm</destination>
  132.                                 </softlinkSource>
  133.                             </sources>
  134.                         </mapping>

  135.                         <mapping>
  136.                             <!-- 配置文件 -->
  137.                             <directory>/usr/local/conf/mvn_rpm</directory>
  138.                             <configuration>true</configuration>
  139.                             <filemode>640</filemode>
  140.                             <username>root</username>
  141.                             <groupname>root</groupname>
  142.                             <sources>
  143.                                 <source>
  144.                                     <location>src/main/conf</location>
  145.                                 </source>
  146.                             </sources>
  147.                         </mapping>
  148.  
  149.                         <mapping>
  150.                             <!-- 日志文件 -->
  151.                             <directory>/usr/local/log/mvn_rpm</directory>
  152.                             <filemode>750</filemode>
  153.                             <username>root</username>
  154.                             <groupname>root</groupname>
  155.                         </mapping>
  156.                     </mappings>

  157.                     <installScriptlet>
  158.                         <script>echo "installing now"</script>
  159.                     </installScriptlet>
  160.                     <postinstallScriptlet>
  161.                         <scriptFile>src/main/scripts/postinstall</scriptFile>
  162.                         <fileEncoding>utf-8</fileEncoding>
  163.                     </postinstallScriptlet>
  164.                     <postremoveScriptlet>
  165.                         <scriptFile>src/main/scripts/preremove</scriptFile>
  166.                         <fileEncoding>utf-8</fileEncoding>
  167.                     </postremoveScriptlet>

  168.                 </configuration>
  169.             </plugin>
  170.         </plugins>



  171.     </build>

  172. </project>



查看打包后,安装涉及到的路径

rpm -qpl target/rpm/study/RPMS/noarch/study-1.0-SNAPSHOT2

安装 :

rpm -ivh target/rpm/study/RPMS/noarch/study-1.0-SNAPSHOT201

删除:

rpm -e study





阅读(2784) | 评论(0) | 转发(0) |
0

上一篇:数据团队组成 - 20140106

下一篇:没有了

给主人留下些什么吧!~~