package org.buildforce.build.maven.zipper.mojo;
/**
*
* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.
*/
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.zip.ZipArchiver;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
/**
* @author mtodorov
*/
public class ZipArtifactTest
{
public static final String TARGET_ZIP_INPUT_DIR = "target/zip";
public static final String TARGET_ZIP_OUTPUT_DIR = "target/zipout";
public static final String ZIP_FILE = "test-permissions.zip";
@Test
public void testZipCreation() throws IOException, ArchiverException
{
File fileWithPermission = new File(TARGET_ZIP_INPUT_DIR, "file.with.permission.sh");
fileWithPermission.setExecutable(true);
File zipFile = new File(TARGET_ZIP_OUTPUT_DIR, ZIP_FILE);
ZipArchiver zipArchiver = new ZipArchiver();
zipArchiver.setDestFile(zipFile);
zipArchiver.setIncludeEmptyDirs(true);
zipArchiver.setCompress(true);
zipArchiver.setForced(true);
zipArchiver.addDirectory(new File(TARGET_ZIP_INPUT_DIR), new String[]{"**/**"}, new String[]{});
zipArchiver.createArchive();
zipArchiver.setIgnorePermissions(false);
zipArchiver.setUseJvmChmod(true);
}
}