Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer project modules on dependency resolution per default #2056

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@

_Baseline is a family of Gradle plugins for configuring Java projects with sensible defaults for code-style, static analysis, dependency versioning, CircleCI and IntelliJ IDEA/Eclipse integration._

| Plugin | Description |
|-----------------------------------------------|------------------------|
| `com.palantir.baseline-idea` | Configures [Intellij IDEA](https://www.jetbrains.com/idea/) with code style and copyright headers
| `com.palantir.baseline-eclipse` | Configures [Eclipse](https://www.eclipse.org/downloads/) with code style and copyright headers
| `com.palantir.baseline-error-prone` | Static analysis for your Java code using Google's [error-prone](http://errorprone.info/).
| `com.palantir.baseline-checkstyle` | Enforces consistent Java formatting using [checkstyle](http://checkstyle.sourceforge.io/)
| `com.palantir.baseline-format` | Formats your java files to comply with checkstyle
| `com.palantir.baseline-scalastyle` | Enforces formatting using [scalastyle](https://github.com/scalastyle/scalastyle)
| `com.palantir.baseline-class-uniqueness` | Analyses your classpath to ensure no fully-qualified class is defined more than once.
| `com.palantir.baseline-circleci` | [CircleCI](https://circleci.com/) integration using `$CIRCLE_ARTIFACTS` and `$CIRCLE_TEST_REPORTS` dirs
| `com.palantir.baseline-config` | Config files for the above plugins
| `com.palantir.baseline-reproducibility` | Sensible defaults to ensure Jar, Tar and Zip tasks can be reproduced
| `com.palantir.baseline-exact-dependencies` | Ensures projects explicitly declare all the dependencies they rely on, no more and no less
| `com.palantir.baseline-encoding` | Ensures projects use the UTF-8 encoding in compile tasks.
| `com.palantir.baseline-release-compatibility` | Ensures projects targeting older JREs only compile against classes and methods available in those JREs.
| `com.palantir.baseline-testing` | Configures test tasks to dump heap dumps (hprof files) for convenient debugging
| `com.palantir.baseline-immutables` | Enables incremental compilation for the [Immutables](http://immutables.github.io/) annotation processor.
| `com.palantir.baseline-java-versions` | Configures JDK versions in a consistent way via Gradle Toolchains.
| Plugin | Description |
|------------------------------------------------|------------------------|
| `com.palantir.baseline-idea` | Configures [Intellij IDEA](https://www.jetbrains.com/idea/) with code style and copyright headers
| `com.palantir.baseline-eclipse` | Configures [Eclipse](https://www.eclipse.org/downloads/) with code style and copyright headers
| `com.palantir.baseline-error-prone` | Static analysis for your Java code using Google's [error-prone](http://errorprone.info/).
| `com.palantir.baseline-checkstyle` | Enforces consistent Java formatting using [checkstyle](http://checkstyle.sourceforge.io/)
| `com.palantir.baseline-format` | Formats your java files to comply with checkstyle
| `com.palantir.baseline-scalastyle` | Enforces formatting using [scalastyle](https://github.com/scalastyle/scalastyle)
| `com.palantir.baseline-class-uniqueness` | Analyses your classpath to ensure no fully-qualified class is defined more than once.
| `com.palantir.baseline-circleci` | [CircleCI](https://circleci.com/) integration using `$CIRCLE_ARTIFACTS` and `$CIRCLE_TEST_REPORTS` dirs
| `com.palantir.baseline-config` | Config files for the above plugins
| `com.palantir.baseline-reproducibility` | Sensible defaults to ensure Jar, Tar and Zip tasks can be reproduced
| `com.palantir.baseline-exact-dependencies` | Ensures projects explicitly declare all the dependencies they rely on, no more and no less
| `com.palantir.baseline-encoding` | Ensures projects use the UTF-8 encoding in compile tasks.
| `com.palantir.baseline-release-compatibility` | Ensures projects targeting older JREs only compile against classes and methods available in those JREs.
| `com.palantir.baseline-testing` | Configures test tasks to dump heap dumps (hprof files) for convenient debugging
| `com.palantir.baseline-immutables` | Enables incremental compilation for the [Immutables](http://immutables.github.io/) annotation processor.
| `com.palantir.baseline-java-versions` | Configures JDK versions in a consistent way via Gradle Toolchains.
| `com.palantir.baseline-prefer-project-modules` | Configures Gradle to prefer project modules over external modules on dependency resolution per default.

See also the [Baseline Java Style Guide and Best Practices](./docs).

Expand Down
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2056.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Prefer project modules on dependency resolution per default
links:
- https://github.com/palantir/gradle-baseline/pull/2056
7 changes: 7 additions & 0 deletions gradle-baseline-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ gradlePlugin {
id = 'com.palantir.baseline-enable-preview-flag'
implementationClass = 'com.palantir.baseline.plugins.BaselineEnablePreviewFlag'
}
baselinePreferProjectModules {
id = 'com.palantir.baseline-prefer-project-modules'
implementationClass = 'com.palantir.baseline.plugins.BaselinePreferProjectModules'
}
}
}

Expand Down Expand Up @@ -130,6 +134,9 @@ pluginBundle {
baselineEnablePreviewFlag {
displayName = 'Palantir Baseline --enable-preview Flag Plugin'
}
baselinePreferProjectModules {
displayName = 'Palantir Baseline Prefer Project Modules Plugin'
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void apply(Project project) {
proj.getPluginManager().apply(BaselineJavaParameters.class);
proj.getPluginManager().apply(BaselineImmutables.class);
proj.getPluginManager().apply(BaselineModuleJvmArgs.class);
proj.getPluginManager().apply(BaselinePreferProjectModules.class);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* (c) Copyright 2022 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.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ResolutionStrategy;

/**
* Prefer project modules that are part of this build over external modules on dependency resolution.
*/
public final class BaselinePreferProjectModules implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getConfigurations()
.configureEach(
configuration -> configuration.resolutionStrategy(ResolutionStrategy::preferProjectModules));
}
}