Skip to content

Commit

Permalink
fix license terms
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi AOKI committed Oct 27, 2014
1 parent ec1ed73 commit 7339f53
Show file tree
Hide file tree
Showing 7 changed files with 613 additions and 54 deletions.
543 changes: 543 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# About
# appbundler-plugin

## About

Maven plugin that creates an Application Bundle for OS X containing all your project dependencies and the necessary metadata.

Expand All @@ -9,7 +11,7 @@ Oracle's [Java Application Bundler](https://java.net/projects/appbundler) suppor

I merged both and fix to work as a maven plugin that supports latest Mac OS X.

# How to build
## How to build

To build native application launcher, run

Expand All @@ -23,7 +25,7 @@ and install
mvn install
```

# How to use
## How to use

A example configuration for pom.xml is followings,

Expand Down Expand Up @@ -60,3 +62,13 @@ Package with following command,
```
mvn package appbundle:bundle
```

## License

Copyright 2014, Takashi AOKI and other contributors.

Copyright 2012, Oracle and/or its affiliates.

`native/main.m` is licensed under the GNU General Public License version 2.

Other files is licensed under the Apache License, Version 2.0.
2 changes: 1 addition & 1 deletion native/main.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2014, Takashi AOKI and other contributors All rights reserved.
* Copyright 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright 2014, Takashi AOKI. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down
101 changes: 51 additions & 50 deletions src/main/java/io/github/appbundler/CreateApplicationBundleMojo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.appbundler;

/*
* Copyright 2014, Takashi AOKI and other contributors.
* Copyright 2001-2008 The Codehaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -302,7 +303,7 @@ public void execute()

System.out.println("Checking for additionalBundledClasspathResources: " + additionalBundledClasspathResources);
if(additionalBundledClasspathResources != null && !additionalBundledClasspathResources.isEmpty()) {
files.addAll(copyAdditionalBundledClasspathResources(javaDirectory, "lib", additionalBundledClasspathResources));
files.addAll(copyAdditionalBundledClasspathResources(javaDirectory, "lib", additionalBundledClasspathResources));
}

// Create and write the Info.plist file
Expand Down Expand Up @@ -438,10 +439,10 @@ private String cleanBundleName(String bundleName) {
return bundleName.replace(':', '-');
}

// private boolean isOSX()
// private boolean isOSX()
// {
// String osName = System.getProperty( "os.name" );
// return osName.equalsIgnoreCase("Mac OS X");
// String osName = System.getProperty( "os.name" );
// return osName.equalsIgnoreCase("Mac OS X");
// }

/**
Expand Down Expand Up @@ -512,14 +513,14 @@ private List<String> copyDependencies(File javaDirectory)
* @throws MojoExecutionException
*/
private List/*<String>*/ copyAdditionalBundledClasspathResources(File javaDirectory, String targetDirectoryName, List/*<FileSet>*/ additionalBundledClasspathResources) throws MojoExecutionException {
// Create the destination directory
File destinationDirectory = new File(javaDirectory, targetDirectoryName);
destinationDirectory.mkdirs();
// Create the destination directory
File destinationDirectory = new File(javaDirectory, targetDirectoryName);
destinationDirectory.mkdirs();

List addedFilenames = copyResources(destinationDirectory, additionalBundledClasspathResources);
List addedFilenames = copyResources(destinationDirectory, additionalBundledClasspathResources);

return addPath(addedFilenames, targetDirectoryName);
}
return addPath(addedFilenames, targetDirectoryName);
}

/**
* Modifies a String list of filenames to include an additional path.
Expand All @@ -528,11 +529,11 @@ private List<String> copyDependencies(File javaDirectory)
* @return
*/
private List addPath(List filenames, String additionalPath) {
ArrayList newFilenames = new ArrayList(filenames.size());
for (int i = 0; i < filenames.size(); i++) {
newFilenames.add(additionalPath + '/' + filenames.get(i));
}
return newFilenames;
ArrayList newFilenames = new ArrayList(filenames.size());
for (int i = 0; i < filenames.size(); i++) {
newFilenames.add(additionalPath + '/' + filenames.get(i));
}
return newFilenames;
}

/**
Expand All @@ -545,14 +546,14 @@ private List addPath(List filenames, String additionalPath) {
private void writeInfoPlist( File infoPlist, List files )
throws MojoExecutionException
{
Velocity.setProperty("file.resource.loader.path", "target/classes" );
try {
Velocity.init();
} catch (Exception e) {
Velocity.setProperty("file.resource.loader.path", "target/classes" );

try {
Velocity.init();
} catch (Exception e) {
throw new MojoExecutionException( "Exception occured in initializing velocity", e);
}
}

VelocityContext velocityContext = new VelocityContext();

velocityContext.put( "mainClass", mainClass );
Expand Down Expand Up @@ -595,30 +596,30 @@ private void writeInfoPlist( File infoPlist, List files )

try
{
File f = new File("target/classes", dictionaryFile);
URI rsrc = null;
if( f.exists() && f.isFile() ) {
rsrc = f.toURI();
String encoding = detectEncoding(rsrc);
File f = new File("target/classes", dictionaryFile);
URI rsrc = null;

if( f.exists() && f.isFile() ) {
rsrc = f.toURI();

String encoding = detectEncoding(rsrc);

getLog().debug( "Detected encoding " + encoding + " for dictionary file " +dictionaryFile );

Writer writer = new OutputStreamWriter( new FileOutputStream(infoPlist), encoding );

Template template = Velocity.getTemplate(dictionaryFile, encoding);

template.merge(velocityContext, writer);

writer.close();
} else {
Writer writer = new OutputStreamWriter( new FileOutputStream(infoPlist), "UTF-8");
} else {
Writer writer = new OutputStreamWriter( new FileOutputStream(infoPlist), "UTF-8");

velocity.getEngine().mergeTemplate( dictionaryFile, "UTF-8", velocityContext, writer );

writer.close();
}
}
}
catch ( IOException e )
{
Expand All @@ -645,8 +646,8 @@ private void writeInfoPlist( File infoPlist, List files )
}

private static String detectEncoding( URI uri ) throws Exception {
byte[] data = Files.readAllBytes(Paths.get(uri));
return new DefaultEncodingDetector().detectXmlEncoding( new ByteArrayInputStream(data) );
byte[] data = Files.readAllBytes(Paths.get(uri));
return new DefaultEncodingDetector().detectXmlEncoding( new ByteArrayInputStream(data) );
}

/**
Expand Down Expand Up @@ -694,21 +695,21 @@ private static String detectEncoding( URI uri ) throws Exception {
* @throws MojoExecutionException In case af a resource copying error.
*/
private List/*<String>*/ copyResources(File targetDirectory, List/*<FileSet>*/ fileSets) throws MojoExecutionException {
ArrayList/*<String>*/ addedFiles = new ArrayList/*<String>*/();
ArrayList/*<String>*/ addedFiles = new ArrayList/*<String>*/();
for ( Iterator it = fileSets.iterator(); it.hasNext(); )
{
FileSet fileSet = (FileSet) it.next();

// Get the absolute base directory for the FileSet
File sourceDirectory = new File(fileSet.getDirectory());
if (!sourceDirectory.isAbsolute()) {
sourceDirectory = new File(project.getBasedir(), sourceDirectory.getPath());
}
if (!sourceDirectory.exists()) {
// If the requested directory does not exist, log it and carry on
// TODO re-instate the logging that was here previously
continue;
}
File sourceDirectory = new File(fileSet.getDirectory());
if (!sourceDirectory.isAbsolute()) {
sourceDirectory = new File(project.getBasedir(), sourceDirectory.getPath());
}
if (!sourceDirectory.exists()) {
// If the requested directory does not exist, log it and carry on
// TODO re-instate the logging that was here previously
continue;
}

List includedFiles = scanFileSet(sourceDirectory, fileSet);
addedFiles.addAll(includedFiles);
Expand All @@ -725,11 +726,11 @@ private static String detectEncoding( URI uri ) throws Exception {
// Make sure that the directory we are copying into exists
destinationFile.getParentFile().mkdirs();

try {
FileUtils.copyFile(source, destinationFile);
} catch (IOException e) {
throw new MojoExecutionException("Error copying additional resource " + source, e);
}
try {
FileUtils.copyFile(source, destinationFile);
} catch (IOException e) {
throw new MojoExecutionException("Error copying additional resource " + source, e);
}
}
}
return addedFiles;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/github/appbundler/FileSet.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.appbundler;

/*
* Copyright 2014, Takashi AOKI and other contributors.
* Copyright 2001-2008 The Codehaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.appbundler.encoding;

/*
* Copyright 2014, Takashi AOKI and other contributors.
* Copyright 2001-2008 The Codehaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.appbundler.encoding;

/*
* Copyright 2014, Takashi AOKI and other contributors.
* Copyright 2001-2008 The Codehaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down

0 comments on commit 7339f53

Please sign in to comment.