Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine selection of binary bundle for macOS based on OS version #54

Merged
merged 40 commits into from
Mar 15, 2017
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
dc91e59
Ported to Eclipse
taxone Aug 27, 2014
7663600
Upgrade to Java 7
taxone Aug 27, 2014
e9f7ad2
Removed Launch4j code. Now Maven dependencies are used.
taxone Sep 2, 2014
51b51f7
.
taxone Sep 2, 2014
2236ed3
Removed commented lines
taxone Sep 2, 2014
0f4de3a
Excludes .idea folder
lukaszlenart Sep 3, 2014
f6d2685
Excludes IBM icu4j to avoid problems with assmbling jar
lukaszlenart Sep 3, 2014
1ab8e04
Moves files to resources folder and drops custom task
lukaszlenart Sep 3, 2014
c74e48b
Performs code cleanup
lukaszlenart Sep 3, 2014
29434f6
Uses Sonatype's parent
lukaszlenart Sep 3, 2014
490c0f0
Cleans pom
lukaszlenart Sep 3, 2014
726fc2c
[maven-release-plugin] prepare release launch4j-maven-plugin-1.6
lukaszlenart Sep 27, 2014
b67eab9
[maven-release-plugin] prepare for next development iteration
lukaszlenart Sep 27, 2014
d62576a
Drops deprecated release guideline
lukaszlenart Sep 30, 2014
5008755
Adds basic readme
lukaszlenart Sep 30, 2014
32b67e4
Adds CI config
lukaszlenart Sep 30, 2014
335b681
Adds build status
lukaszlenart Sep 30, 2014
e8bb818
Adds info how to solve problem with missing dsol-xml dependency
lukaszlenart Sep 30, 2014
82c1c18
Adds support for runtimeBits
lukaszlenart Sep 30, 2014
503486d
Adds info about SNAPSHOT repo
lukaszlenart Sep 30, 2014
922ee3b
Adds missing slash
lukaszlenart Oct 2, 2014
92f71de
Adds runtimeBits @parameter definition and toString for better debugging
lukaszlenart Oct 10, 2014
d705285
Adds toString for better debugging
lukaszlenart Oct 10, 2014
74d3ed5
Includes runtime artifacts in final class path, closes #5
lukaszlenart Oct 10, 2014
1dd734e
Adds info about required Java version
lukaszlenart Oct 11, 2014
9c59758
Upgrades Launch4j version to 3.5.0
lukaszlenart Oct 16, 2014
53f037d
Changes compiler target to 1.7
lukaszlenart Oct 16, 2014
52f5ab3
Drops failing plugin
lukaszlenart Oct 16, 2014
f18cea1
[maven-release-plugin] prepare release launch4j-maven-plugin-1.7
lukaszlenart Oct 17, 2014
122fad9
[maven-release-plugin] prepare for next development iteration
lukaszlenart Oct 17, 2014
32319cf
Updates version notes for 1.7
lukaszlenart Oct 17, 2014
0bade86
Converts into links
lukaszlenart Oct 17, 2014
940a3e2
Adds proper path
lukaszlenart Oct 17, 2014
07a7b1f
Adds one more level to path
lukaszlenart Oct 17, 2014
fa32ac3
Merge branch 'master' of https://github.com/lukaszlenart/launch4j-mav…
thomas3 Nov 29, 2015
26e2cf0
Merge branch 'master' of https://github.com/lukaszlenart/launch4j-mav…
thomas3 Apr 28, 2016
b3a443a
Merge branch 'master' of https://github.com/lukaszlenart/launch4j-mav…
thomas3 Mar 5, 2017
f867ce5
Refine the selection of the platform specific binary bundle for macOS
thomas3 Mar 12, 2017
cd9ae03
Removed outdated README file
thomas3 Mar 12, 2017
0fc105a
Refactored macOS system version detection
thomas3 Mar 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 27 additions & 28 deletions src/main/java/com/akathist/maven/plugins/launch4j/Launch4jMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,34 @@
*/
package com.akathist.maven.plugins.launch4j;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import net.sf.launch4j.Builder;
import net.sf.launch4j.BuilderException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;

import net.sf.launch4j.config.ConfigPersisterException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.plugins.annotations.*;
import org.apache.maven.project.MavenProject;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

/**
* Wraps a jar in a Windows executable.
*/
Expand Down Expand Up @@ -462,14 +451,16 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException {
File platJar = a.getFile();
File dest = platJar.getParentFile();
File marker = new File(dest, platJar.getName() + ".unpacked");
String n = platJar.getName();
File workdir = new File(dest, n.substring(0, n.length() - 4));

// If the artifact is a SNAPSHOT, then a.getVersion() will report the long timestamp,
// but getFile() will be 1.1-SNAPSHOT.
// Since getFile() doesn't use the timestamp, all timestamps wind up in the same place.
// Therefore we need to expand the jar every time, if the marker file is stale.
if (marker.exists() && marker.lastModified() > platJar.lastModified()) {
// if (marker.exists() && marker.platJar.getName().indexOf("SNAPSHOT") == -1) {
getLog().info("Platform-specific work directory already exists: " + dest.getAbsolutePath());
getLog().info("Platform-specific work directory already exists: " + workdir.getAbsolutePath());
} else {
JarFile jf = null;
try {
Expand Down Expand Up @@ -526,8 +517,6 @@ private File unpackWorkDir(Artifact a) throws MojoExecutionException {
}
}

String n = platJar.getName();
File workdir = new File(dest, n.substring(0, n.length() - 4));
setPermissions(workdir);
return workdir;
}
Expand Down Expand Up @@ -608,7 +597,7 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
} else if ("Solaris".equals(os) || "SunOS".equals(os)) {
plat = "solaris";
} else if ("Mac OS X".equals(os) || "Darwin".equals(os)) {
plat = "mac";
plat = isBelowMacOSX_10_8() ? "mac" : "osx";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that in contrary to what Grzegorz wrote at https://sourceforge.net/p/launch4j/bugs/160/#95fd ?!

launch4j-3.9-workdir-mac.jar and launch4j-3.9-workdir-osx.jar. osx is the 10.8 version.

But you're using the mac version for isBelowMacOSX_10_8() ?!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that there is just one package for OSX
https://sourceforge.net/p/launch4j/bugs/160/#59fc

} else {
throw new MojoExecutionException("Sorry, Launch4j doesn't support the '" + os + "' OS.");
}
Expand All @@ -617,6 +606,16 @@ private Artifact chooseBinaryBits() throws MojoExecutionException {
getLaunch4jVersion(), "jar", "workdir-" + plat);
}

private static boolean isBelowMacOSX_10_8() {
String[] parts = System.getProperty("os.version").split("\\.");
try {
int major = Integer.parseInt(parts[0]);
int minor = Integer.parseInt(parts[1]);
return (major < 10) || (major == 10) && (minor < 8);
} catch (NumberFormatException e) {
return false;
}
}

private File getBaseDir() {
return basedir;
Expand Down Expand Up @@ -739,4 +738,4 @@ private String getLaunch4jVersion() throws MojoExecutionException {

return version;
}
}
}