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

com.palantir.baseline.plugins.Baseline Maven / Gradle / Ivy

The newest version!
/*
 * (c) Copyright 2015 Palantir Technologies Inc. All rights reserved.
 *
 * 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 com.palantir.baseline.plugins;

import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.util.GradleVersion;

/** A Plugin that configures a project with all Baseline settings. */
public final class Baseline implements Plugin {
    public static final GradleVersion MIN_GRADLE_VERSION = GradleVersion.version("7.0");

    @Override
    public void apply(Project project) {
        if (GradleVersion.current().compareTo(MIN_GRADLE_VERSION) < 0) {
            throw new GradleException(String.format(
                    "The minimum supported Gradle version is version %s but got version %s",
                    MIN_GRADLE_VERSION, GradleVersion.current()));
        }

        Project rootProject = project.getRootProject();
        if (!project.equals(rootProject)) {
            project.getLogger()
                    .warn(
                            "com.palantir.baseline should be applied to the root project only, not '{}'",
                            project.getName());
        }

        rootProject.getPluginManager().apply(BaselineConfig.class);
        rootProject.getPluginManager().apply(BaselineCircleCi.class);
        rootProject.allprojects(proj -> {
            proj.getPluginManager().apply(BaselineCheckstyle.class);
            proj.getPluginManager().apply(BaselineScala.class);
            // these are groovy-based classes so java has trouble with cross compiler
            proj.getPluginManager().apply("com.palantir.baseline-eclipse");
            proj.getPluginManager().apply("com.palantir.baseline-idea");
            proj.getPluginManager().apply(BaselineErrorProne.class);
            proj.getPluginManager().apply(BaselineFormat.class);
            proj.getPluginManager().apply(BaselineEncoding.class);
            proj.getPluginManager().apply(BaselineReproducibility.class);
            proj.getPluginManager().apply(BaselineClassUniquenessPlugin.class);
            proj.getPluginManager().apply(BaselineExactDependencies.class);
            proj.getPluginManager().apply(BaselineReleaseCompatibility.class);
            proj.getPluginManager().apply(BaselineTesting.class);
            proj.getPluginManager().apply(BaselineTestHeap.class);
            proj.getPluginManager().apply(BaselineJavaCompilerDiagnostics.class);
            proj.getPluginManager().apply(BaselineJavaCompilerHeap.class);
            proj.getPluginManager().apply(BaselineJavaParameters.class);
            proj.getPluginManager().apply(BaselineImmutables.class);
            proj.getPluginManager().apply(BaselineModuleJvmArgs.class);
            proj.getPluginManager().apply(BaselinePreferProjectModules.class);
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy