Skip to content

Commit

Permalink
Merge pull request #15 from hazendaz/master
Browse files Browse the repository at this point in the history
Update to use Maven Annotations
  • Loading branch information
lukaszlenart committed Dec 30, 2014
2 parents 01f8b06 + 433830a commit e773e9c
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ target/*
.settings/*
.project
.classpath
.factorypath
/target
.idea
75 changes: 70 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.2.3</version>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand All @@ -79,12 +85,12 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-descriptor</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -103,7 +109,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5</version>
<version>2.5.3</version>
<executions>
<execution>
<id>dist-src</id>
Expand All @@ -119,7 +125,66 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<configuration>
<!-- see http://jira.codehaus.org/browse/MNG-5346 -->
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
<execution>
<id>help-goal</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-plugin-plugin
</artifactId>
<versionRange>
[3.3,)
</versionRange>
<goals>
<goal>helpmojo</goal>
<goal>descriptor</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<reporting>
Expand Down Expand Up @@ -147,7 +212,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
<version>2.18.1</version>
</plugin>
</plugins>
</reporting>
Expand Down
29 changes: 12 additions & 17 deletions src/main/java/com/akathist/maven/plugins/launch4j/ClassPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.akathist.maven.plugins.launch4j;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugins.annotations.Parameter;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -29,56 +30,51 @@ public class ClassPath {

/**
* The main class to run. This is not required if you are wrapping an executable jar.
*
* @parameter
*/
@Parameter
String mainClass;

/**
* The launch4j executable sets up a classpath before running your jar, but it must know what the
* classpath should be. If you set this property to true, the plugin will indicate a classpath
* based on all the dependencies your program will need at runtime. You can augment this classpath
* using the preCp and postCp properties.
*
* @parameter default-value=true
*/
@Parameter(defaultValue="true")
boolean addDependencies = true;

/**
* If you want maven to build the classpath from dependencies, you can optionally set the jarLocation,
* which is the location of the jars in your distro relative to the executable. So if your distro
* has the exe at the top level and all the jars in a lib directory, you could set this to &quot;lib.&quot;
* This property does not affect preCp and postCp.
*
* @parameter
*/
@Parameter
String jarLocation;

/**
* Part of the classpath that the executable should give to your application.
* Paths are relative to the executable and should be in Windows format (separated by a semicolon).
* You don't have to list all your dependencies here; the plugin will include them by default
* after this list.
*
* @parameter
*/
@Parameter
String preCp;

/**
* Part of the classpath that the executable should give to your application.
* Paths are relative to the executable and should be in Windows format (separated by a semicolon).
* You don't have to list all your dependencies here; the plugin will include them by default
* before this list.
*
* @parameter
*/
@Parameter
String postCp;

private void addToCp(List<String> cp, String cpStr) {
cp.addAll(Arrays.asList(cpStr.split("\\s*;\\s*")));
}

net.sf.launch4j.config.ClassPath toL4j(Set dependencies, List runtimeDependencies) {
net.sf.launch4j.config.ClassPath toL4j(Set<Artifact> dependencies, List<Artifact> runtimeDependencies) {
net.sf.launch4j.config.ClassPath ret = new net.sf.launch4j.config.ClassPath();
ret.setMainClass(mainClass);

Expand All @@ -92,14 +88,13 @@ net.sf.launch4j.config.ClassPath toL4j(Set dependencies, List runtimeDependencie
// Add all runtime dependencies as we need them to run the wrapped jar
dependencies.addAll(runtimeDependencies);

for (Object dependency : dependencies) {
Artifact dep = (Artifact) dependency;
if (Artifact.SCOPE_COMPILE.equals(dep.getScope()) ||
Artifact.SCOPE_RUNTIME.equals(dep.getScope())) {
for (Artifact dependency : dependencies) {
if (Artifact.SCOPE_COMPILE.equals(dependency.getScope()) ||
Artifact.SCOPE_RUNTIME.equals(dependency.getScope())) {

String depFilename;
depFilename = dep.getFile().getName();
// System.out.println("dep = " + depFilename);
depFilename = dependency.getFile().getName();
// System.out.println("dependency = " + depFilename);
cp.add(jarLocation + depFilename);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/akathist/maven/plugins/launch4j/Jre.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.util.List;

import org.apache.maven.plugins.annotations.Parameter;

/**
* Details about which jre the executable should call.
*/
Expand Down Expand Up @@ -79,9 +81,8 @@ public class Jre {
* <td>Always use a private JDK runtime (fails if there is no JDK installed)</td>
* </tr>
* </table>
*
* @parameter default-value="preferJre"
*/
@Parameter(defaultValue="preferJre")
String jdkPreference;

/**
Expand Down Expand Up @@ -120,9 +121,8 @@ public class Jre {
* Sets JVM version to use: 32 bits, 64 bits or 64/32 bits
* Possible values: 32, 64, 64/32 - it will fallback to default value if different option was used
* Default value is: 64/32
*
* @parameter default-value="64/32"
*/
@Parameter(defaultValue="64/32")
String runtimeBits;

net.sf.launch4j.config.Jre toL4j() {
Expand Down
Loading

0 comments on commit e773e9c

Please sign in to comment.