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

org.apache.maven.shared.archiver.MavenArchiveConfiguration Maven / Gradle / Ivy

Go to download

Provides utility methods for creating JARs and other archive files from a Maven project.

The newest version!
/*
 * 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.maven.shared.archiver;

import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Capture common archive configuration.
 *
 * @author Brett Porter
 */
// TODO Is this general enough to be in Plexus Archiver?
public class MavenArchiveConfiguration {
    private boolean compress = true;

    private boolean recompressAddedZips = true;

    private boolean addMavenDescriptor = true;

    private Path manifestFile;

    // TODO: Rename this attribute to manifestConfiguration;
    private ManifestConfiguration manifest;

    private Map manifestEntries = new LinkedHashMap<>();

    private List manifestSections = new LinkedList<>();

    /**
     * @since 2.2
     */
    private boolean forced = true;

    /**
     * @since 2.3
     */
    private Path pomPropertiesFile;

    /**
     * 

isCompress.

* * @return {@link #compress} */ public boolean isCompress() { return compress; } /** *

isRecompressAddedZips.

* * @return {@link #recompressAddedZips} */ public boolean isRecompressAddedZips() { return recompressAddedZips; } /** *

Setter for the field recompressAddedZips.

* * @param recompressAddedZips {@link #recompressAddedZips} */ public void setRecompressAddedZips(boolean recompressAddedZips) { this.recompressAddedZips = recompressAddedZips; } /** *

isAddMavenDescriptor.

* * @return {@link #addMavenDescriptor} */ public boolean isAddMavenDescriptor() { return addMavenDescriptor; } /** *

Getter for the field manifestFile.

* * @return {@link #manifestFile} */ public Path getManifestFile() { return manifestFile; } /** *

Getter for the field manifest.

* * @return {@link #manifest} */ // TODO: Change the name of this method into getManifestConfiguration() public ManifestConfiguration getManifest() { if (manifest == null) { manifest = new ManifestConfiguration(); } return manifest; } /** *

Setter for the field compress.

* * @param compress set compress to true/false. */ public void setCompress(boolean compress) { this.compress = compress; } /** *

Setter for the field addMavenDescriptor.

* * @param addMavenDescriptor activate to add maven descriptor or not. */ public void setAddMavenDescriptor(boolean addMavenDescriptor) { this.addMavenDescriptor = addMavenDescriptor; } /** *

Setter for the field manifestFile.

* * @param manifestFile The manifest file. */ public void setManifestFile(Path manifestFile) { this.manifestFile = manifestFile; } /** *

Setter for the field manifest.

* * @param manifest {@link ManifestConfiguration} */ public void setManifest(ManifestConfiguration manifest) { this.manifest = manifest; } /** *

addManifestEntry.

* * @param key The key of the entry. * @param value The value of the entry. */ public void addManifestEntry(String key, String value) { manifestEntries.put(key, value); } /** *

addManifestEntries.

* * @param map The whole map which should be added. */ public void addManifestEntries(Map map) { manifestEntries.putAll(map); } /** *

isManifestEntriesEmpty.

* * @return are there entries true yes false otherwise. */ public boolean isManifestEntriesEmpty() { return manifestEntries.isEmpty(); } /** *

Getter for the field manifestEntries.

* * @return {@link #manifestEntries} */ public Map getManifestEntries() { return manifestEntries; } /** *

Setter for the field manifestEntries.

* * @param manifestEntries {@link #manifestEntries} */ public void setManifestEntries(Map manifestEntries) { this.manifestEntries = manifestEntries; } /** *

addManifestSection.

* * @param section {@link ManifestSection} */ public void addManifestSection(ManifestSection section) { manifestSections.add(section); } /** *

addManifestSections.

* * @param list Added list of {@link ManifestSection}. */ public void addManifestSections(List list) { manifestSections.addAll(list); } /** *

isManifestSectionsEmpty.

* * @return if manifestSections is empty or not. */ public boolean isManifestSectionsEmpty() { return manifestSections.isEmpty(); } /** *

Getter for the field manifestSections.

* * @return {@link #manifestSections} */ public List getManifestSections() { return manifestSections; } /** *

Setter for the field manifestSections.

* * @param manifestSections set The list of {@link ManifestSection}. */ public void setManifestSections(List manifestSections) { this.manifestSections = manifestSections; } /** *

* Returns, whether recreating the archive is forced (default). Setting this option to false means, that the * archiver should compare the timestamps of included files with the timestamp of the target archive and rebuild the * archive only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically * offer a performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files * won't be detected. *

*

* An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be * ignored. *

* * @return True, if the target archive should always be created; false otherwise * @see #setForced(boolean) */ public boolean isForced() { return forced; } /** *

* Sets, whether recreating the archive is forced (default). Setting this option to false means, that the archiver * should compare the timestamps of included files with the timestamp of the target archive and rebuild the archive * only, if the latter timestamp precedes the former timestamps. Checking for timestamps will typically offer a * performance gain (in particular, if the following steps in a build can be suppressed, if an archive isn't * recrated) on the cost that you get inaccurate results from time to time. In particular, removal of source files * won't be detected. *

*

* An archiver doesn't necessarily support checks for uptodate. If so, setting this option to true will simply be * ignored. *

* * @param forced True, if the target archive should always be created; false otherwise * @see #isForced() */ public void setForced(boolean forced) { this.forced = forced; } /** * Returns the location of the "pom.properties" file. May be null, in which case a default value is choosen. * * @return "pom.properties" location or null. */ public Path getPomPropertiesFile() { return pomPropertiesFile; } /** * Sets the location of the "pom.properties" file. May be null, in which case a default value is choosen. * * @param pomPropertiesFile "pom.properties" location or null. */ public void setPomPropertiesFile(Path pomPropertiesFile) { this.pomPropertiesFile = pomPropertiesFile; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy