/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.sis.internal.maven;

import java.io.File;
import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;


/**
 * Merges the binaries produced by <code>JarCollector</code> and compress them using Pack200.
 * This mojo delegates the work to <code>Packer</code>, which can be invoked from the command
 * line without Maven. Maven invocation syntax is:
 *
 * <blockquote><code>mvn org.apache.sis:sis-build-helper:pack --non-recursive</code></blockquote>
 *
 * Do not forget the <code>--non-recursive</code> option, otherwise the Mojo will be executed many time.
 *
 * @author  Martin Desruisseaux (Geomatys)
 * @since   0.3 (derived from geotk-3.00)
 * @version 0.3
 * @module
 *
 * @goal pack
 * @phase install
 */
public class BundleCreator extends AbstractMojo {
    /**
     * The Apache SIS version.
     */
    private static final String VERSION = "0.3-jdk7";

    /**
     * The root directory (without the "<code>target/binaries</code>" sub-directory) where JARs
     * are to be copied. It should be the directory of the root <code>pom.xml</code>.
     *
     * @parameter property="session.executionRootDirectory"
     * @required
     */
    private String rootDirectory;

    /**
     * Creates the Pack200 files from the JAR files collected in the "<code>target/binaries</code>" directory.
     *
     * @throws MojoExecutionException if the plugin execution failed.
     */
    @Override
    public void execute() throws MojoExecutionException {
        final File targetDirectory = new File(rootDirectory, JarCollector.TARGET_DIRECTORY);
        if (!targetDirectory.isDirectory()) {
            throw new MojoExecutionException("Directory not found: " + targetDirectory);
        }
        try {
            final Packer packer = new Packer(targetDirectory, VERSION);
            packer.addPack("sis-" + VERSION + ".jar");
            try {
                packer.createJars();
            } finally {
                packer.close();
            }
            packer.pack();
        } catch (IOException e) {
            throw new MojoExecutionException(e.getLocalizedMessage(), e);
        }
    }
}

@@ -1679,16 +1679,37 @@
  version
+, without branch name
 .%0A     *
@@ -1756,17 +1756,305 @@
 N = %220.3
--
+%22;%0A%0A    /**%0A     * The Apache SIS branch for which this plugin is creating a bundle.%0A     * This is declared as a separated constant in order to make easier to update%0A     * %7B@link #VERSION%7D without creating conflicts during branch merge.%0A     */%0A    private static final String BRANCH = %22
 jdk7%22;%0A%0A
@@ -2890,32 +2890,95 @@
 %7D%0A        try %7B%0A
+            final String fullVersion = VERSION + '-' + BRANCH;%0A
             fina
@@ -3023,23 +3023,27 @@
 ectory, 
-VERSION
+fullVersion
 );%0A     
@@ -3073,23 +3073,27 @@
 sis-%22 + 
-VERSION
+fullVersion
  + %22.jar

Separate version number from branch name for easier merges.