All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evolvedbinary.appbundler.AppBundlerMojo Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/*
 * Much of this code was originally taken from Oracle's
 * App Bundler class com.oracle.appbundler.AppBundlerTask
 * and some modifications made by Adam Retter.
 * The original copyright and license follows...
 */

/*
 * Copyright 2012, Oracle and/or its affiliates. All rights reserved.
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.evolvedbinary.appbundler;

import com.oracle.appbundler.IconContainer;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.FlatRepositoryLayout;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
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.project.MavenProject;
import org.apache.maven.shared.model.fileset.FileSet;
import org.apache.maven.shared.model.fileset.util.FileSetManager;
import org.sonatype.aether.util.layout.RepositoryLayout;

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import static java.nio.charset.StandardCharsets.UTF_8;

/**
 * Goal which touches a timestamp file.
 */
@Mojo(name = "bundle", defaultPhase = LifecyclePhase.PACKAGE, requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true)
public class AppBundlerMojo extends AbstractMojo {

    private static final String APPBUNDLER_PACKAGE_PATH = "com/oracle/appbundler";
    private static final String APP_ROOT_PREFIX = "$APP_ROOT";

    private static final String PLIST_DTD = "";
    private static final String PLIST_TAG = "plist";
    private static final String PLIST_VERSION_ATTRIBUTE = "version";
    private static final String DICT_TAG = "dict";
    private static final String KEY_TAG = "key";
    private static final String ARRAY_TAG = "array";
    private static final String STRING_TAG = "string";

    private static final String EXECUTABLE_NAME = "JavaAppLauncher";
    private static final String DEFAULT_ICON_NAME = "GenericApp.icns";
    private static final String OS_TYPE_CODE = "APPL";

    @Parameter(defaultValue = "${project.runtimeArtifacts}", readonly = true)
    private List artifacts;

    @Parameter(defaultValue = "${project}", readonly = true, required = true)
    private MavenProject mavenProject;

    /**
     *  Output folder for generated bundle
     */
    @Parameter(required = true, defaultValue = "${project.build.directory}")
    private File outputDirectory;


    /* General bundle properties */

    @Parameter(required = true, defaultValue = "${project.artifactId}-${project.version}")
    private String name;

    @Parameter(required = true)
    private String displayName;

    @Parameter(required = true)
    private String identifier;

    @Parameter
    private File icon;

    @Parameter(defaultValue = EXECUTABLE_NAME)
    private String executableName;

    @Parameter(defaultValue = "${project.version}")
    private String shortVersion = "1.0";

    @Parameter(defaultValue = "${project.version}")
    private String version;

    @Parameter(defaultValue = "????")
    private String signature;

    @Parameter
    private String copyright;

    @Parameter
    private String privileged;

    @Parameter
    private String workingDirectory;

    @Parameter
    private String minimumSystemVersion;

    @Parameter
    private String jvmRequired = null;

    @Parameter(defaultValue = "false")
    private boolean jrePreferred;

    @Parameter(defaultValue = "false")
    private boolean jdkPreferred;

    @Parameter
    private String applicationCategory;

    @Parameter(defaultValue = "true")
    private boolean highResolutionCapable;

    @Parameter(defaultValue = "true")
    private boolean supportsAutomaticGraphicsSwitching;

    @Parameter(defaultValue = "false")
    private boolean hideDockIcon;

    @Parameter(defaultValue = "false")
    private boolean isDebug;

    @Parameter(defaultValue = "false")
    private boolean ignorePSN;

    /* JVM info properties */
    @Parameter
    private String mainClassName;

    @Parameter
    private String jnlpLauncherName;

    @Parameter
    private String jarLauncherName;

    //TODO(AR) needs to be configurable by parameters
    private Runtime runtime;

    @Parameter
    private List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy