org.gradle.api.distribution.plugins.DistributionPlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2012 the original author or authors.
*
* 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.
*/
package org.gradle.api.distribution.plugins;
import org.codehaus.groovy.runtime.StringGroovyMethods;
import org.gradle.api.Action;
import org.gradle.api.GradleException;
import org.gradle.api.Incubating;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.distribution.Distribution;
import org.gradle.api.distribution.internal.DefaultDistributionContainer;
import org.gradle.api.file.CopySpec;
import org.gradle.api.internal.IConventionAware;
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact;
import org.gradle.api.internal.file.FileOperations;
import org.gradle.api.internal.plugins.DefaultArtifactPublicationSet;
import org.gradle.api.internal.project.ProjectInternal;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.tasks.Sync;
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
import org.gradle.api.tasks.bundling.Tar;
import org.gradle.api.tasks.bundling.Zip;
import org.gradle.internal.reflect.Instantiator;
import javax.inject.Inject;
import java.io.File;
import java.util.concurrent.Callable;
/**
* A {@link Plugin} to package project as a distribution.
*/
@Incubating
public class DistributionPlugin implements Plugin {
/**
* Name of the main distribution
*/
public static final String MAIN_DISTRIBUTION_NAME = "main";
public static final String TASK_INSTALL_NAME = "installDist";
private static final String DISTRIBUTION_GROUP = "distribution";
private static final String TASK_DIST_ZIP_NAME = "distZip";
private static final String TASK_DIST_TAR_NAME = "distTar";
private static final String TASK_ASSEMBLE_NAME = "assembleDist";
private final Instantiator instantiator;
private final FileOperations fileOperations;
@Inject
public DistributionPlugin(Instantiator instantiator, FileOperations fileOperations) {
this.instantiator = instantiator;
this.fileOperations = fileOperations;
}
@Override
public void apply(final ProjectInternal project) {
project.getPluginManager().apply(BasePlugin.class);
DefaultDistributionContainer distributions = project.getExtensions().create("distributions", DefaultDistributionContainer.class, Distribution.class, instantiator, fileOperations);
// TODO - refactor this action out so it can be unit tested
distributions.all(new Action() {
@Override
public void execute(final Distribution dist) {
((IConventionAware) dist).getConventionMapping().map("baseName", new Callable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy