应用Maven-Assembly-Plugin插件构建可执行软件包

pom.xml

<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.0modelVersion>
  <groupId>net.mrliuligroupId>
  <artifactId>I18nResourceGeneratorartifactId>
  <packaging>jarpackaging>
  <version>1.0-SNAPSHOTversion>
  <name>I18nResourceGeneratorname>
  <url>http://maven.apache.orgurl>
  <dependencies>

    <dependency>
      <groupId>junitgroupId>
      <artifactId>junitartifactId>
      <version>3.8.1version>
      <scope>testscope>
    dependency>

    <dependency>
      <groupId>org.apache.poigroupId>
      <artifactId>poiartifactId>
      <version>3.13version>
    dependency>

    
      
      
      
    

  dependencies>

  
    
  

  <build>

    <finalName>i18nGeneratorfinalName>

    <plugins>

      
      <plugin>
        <artifactId>maven-compiler-pluginartifactId>
        <version>3.1version>
        <configuration>
          <source>1.7source>
          <target>1.7target>
          <encoding>UTF-8encoding>
        configuration>
      plugin>

      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <version>2.5version>
        <artifactId>maven-resources-pluginartifactId>
        <configuration>
          <encoding>UTF-8encoding>
        configuration>
      plugin>

      

      


      
      
      
        
        
        
        
          
          
            
            

            
            

              
              
              

            
          
        
      

      
      
        
        
        
          
            
            
            
              
            
            
              
                
              
            
          
        
      

      
      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-assembly-pluginartifactId>
        <version>3.0.0version>

        
        
        <executions>                    
          <execution>
            <id>make-assemblyid>      
            <phase>packagephase>      
            <goals>
              <goal>singlegoal>       
            goals>
            <configuration>
              <appendAssemblyId>falseappendAssemblyId>
              <descriptors>
                <descriptor>${project.basedir}/src/main/resources/assembly.xmldescriptor>     
                
              descriptors>
            configuration>
          execution>
        executions>
      plugin>

      <plugin>
        <groupId>org.apache.maven.pluginsgroupId>
        <artifactId>maven-jar-pluginartifactId>
        <configuration>
          <archive>
            <addMavenDescriptor>falseaddMavenDescriptor>    
            
            <manifest>
              <mainClass>net.mrliuli.AppmainClass>       
              <addClasspath>trueaddClasspath>                 
              <classpathPrefix>lib/classpathPrefix>          
            manifest>
          archive>
        configuration>
      plugin>



      
      
        
        
        
        
          
            
            
            
              
            
          
        
      

      
      
        
        
        
        
          
            
            
              
            
          
        
      


      

      
        
        
        
        
          
            
            
              
            
            

              
                
                  
                
              

              
              
                
              
              
                
              

            
          
        
      

    plugins>

  build>

project>

assembly.xml

<assembly xmlns="http://maven.apache.org/ASSEMBLY/3.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/3.0.0 http://maven.apache.org/xsd/assembly-3.0.0.xsd">

    <id>assemblyid>

    <formats>
        <format>zipformat>                                    
    formats>

    
    <fileSets>

        <fileSet>
            <directory>${project.basedir}/src/main/resources/directory>
            <outputDirectory>/resourcesoutputDirectory>
            <excludes>
                <exclude>assembly.xmlexclude>
            excludes>
        fileSet>

        
        <fileSet>
            <directory>${project.build.directory}/directory>
            <outputDirectory>/outputDirectory>
            <includes>
                <include>*.jarinclude>
            includes>
        fileSet>

        
        <fileSet>
            <directory>${java.home}directory>
            <outputDirectory>/jreoutputDirectory>
        fileSet>

        <fileSet>
            <outputDirectory>/outputDirectory>
            <includes>
                <include>README.*include>
                <include>LICENCE.*include>
                <include>run.*include>
            includes>
        fileSet>

    fileSets>



    
    <dependencySets>
        <dependencySet>
            <outputDirectory>/liboutputDirectory>
            <useProjectArtifact>falseuseProjectArtifact>      
            <scope>runtimescope>                              
        dependencySet>
    dependencySets>


assembly>

你可能感兴趣的:(Java,Maven)