maven生成exe文件

1、编写源代码

[java]  view plain  copy
 print ?
  1. package org.pzy.exe_test;  
  2.   
  3. import javax.swing.JColorChooser;  
  4. import javax.swing.JDialog;  
  5.   
  6. /** 
  7.  * Hello world! 
  8.  *  
  9.  */  
  10. public class Main extends JDialog {  
  11.     private static final long serialVersionUID = 1L;  
  12.     private final JColorChooser cc;  
  13.   
  14.     public Main() {  
  15.         setSize(800600);  
  16.         setTitle("hasCode.com launch4j Maven Tutorial");  
  17.         cc = new JColorChooser();  
  18.         add(cc);  
  19.         setDefaultCloseOperation(DISPOSE_ON_CLOSE);  
  20.         setVisible(true);  
  21.     }  
  22.   
  23.     public static void main(final String[] args) {  
  24.         new Main();  
  25.     }  
  26.   
  27. }  

2、配置pom

[html]  view plain  copy
 print ?
  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.0modelVersion>  
  4.   
  5.     <groupId>org.pzygroupId>  
  6.     <artifactId>exe-testartifactId>  
  7.     <version>0.0.1-SNAPSHOTversion>  
  8.     <packaging>jarpackaging>  
  9.   
  10.     <name>exe-testname>  
  11.     <url>http://maven.apache.orgurl>  
  12.   
  13.     <properties>  
  14.         <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>  
  15.     properties>  
  16.     <build>  
  17.         <plugins>  
  18.             <plugin>  
  19.                 <groupId>org.apache.maven.pluginsgroupId>  
  20.                 <artifactId>maven-compiler-pluginartifactId>  
  21.                 <configuration>  
  22.                     <source>1.7source>  
  23.                     <target>1.7target>  
  24.                 configuration>  
  25.             plugin>  
  26.             <plugin>  
  27.                 <groupId>org.apache.maven.pluginsgroupId>  
  28.                 <artifactId>maven-shade-pluginartifactId>  
  29.                 <executions>  
  30.                     <execution>  
  31.                         <phase>packagephase>  
  32.                         <goals>  
  33.                             <goal>shadegoal>  
  34.                         goals>  
  35.                     execution>  
  36.                 executions>  
  37.                 <configuration>  
  38.                     <shadedArtifactAttached>trueshadedArtifactAttached>  
  39.                     <shadedClassifierName>shadedshadedClassifierName>  
  40.                     <transformers>  
  41.                         <transformer  
  42.                             implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
  43.                             <mainClass>org.pzy.exe_test.MainmainClass>  
  44.                         transformer>  
  45.                     transformers>  
  46.                 configuration>  
  47.             plugin>  
  48.             <plugin>  
  49.                 <groupId>com.akathist.maven.plugins.launch4jgroupId>  
  50.                 <artifactId>launch4j-maven-pluginartifactId>  
  51.                 <executions>  
  52.                     <execution>  
  53.                         <id>l4j-cluiid>  
  54.                         <phase>packagephase>  
  55.                         <goals>  
  56.                             <goal>launch4jgoal>  
  57.                         goals>  
  58.                         <configuration>  
  59.                             <headerType>guiheaderType>  
  60.                             <jar>${project.build.directory}/${artifactId}-${version}-shaded.jarjar>  
  61.                             <outfile>${project.build.directory}/hasCode.exeoutfile>  
  62.                             <downloadUrl>http://java.com/downloaddownloadUrl>  
  63.                             <classPath>  
  64.                                 <mainClass>org.pzy.exe_test.MainmainClass>  
  65.                                 <preCp>anythingpreCp>  
  66.                             classPath>  
  67.                             <icon>src/resources/0.icoicon>  
  68.                             <jre>  
  69.                                 <minVersion>1.7.0minVersion>  
  70.                                 <jdkPreference>preferJrejdkPreference>  
  71.                             jre>  
  72.                             <versionInfo>  
  73.                                 <fileVersion>1.0.0.0fileVersion>  
  74.                                 <txtFileVersion>${project.version}txtFileVersion>  
  75.                                 <fileDescription>${project.name}fileDescription>  
  76.                                 <copyright>2012 hasCode.comcopyright>  
  77.                                 <productVersion>1.0.0.0productVersion>  
  78.                                 <txtProductVersion>1.0.0.0txtProductVersion>  
  79.                                 <productName>${project.name}productName>  
  80.                                 <companyName>hasCode.comcompanyName>  
  81.                                 <internalName>hasCodeinternalName>  
  82.                                 <originalFilename>hasCode.exeoriginalFilename>  
  83.                             versionInfo>  
  84.                         configuration>  
  85.                     execution>  
  86.                 executions>  
  87.             plugin>  
  88.         plugins>  
  89.     build>  
  90. project>  

3、执行maven命令

[plain]  view plain  copy
 print ?
  1. package  



<headerType>guiheaderType>  生成gui程序
<headerType>consoleheaderType>  生成控制台程序



    bin/jre			//这一段指定绑定jre的路径
    true
    false
    
    
    preferJre
    64/32
  


你可能感兴趣的:(maven)