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

Extension requiring external libraries on demand use the buildscript of the root project for lookup #123

Merged
merged 2 commits into from
Jul 11, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;

import com.diffplug.common.base.StringPrinter;
import com.diffplug.spotless.Provisioner;

/** Gradle integration for Provisioner. */
Expand All @@ -36,11 +37,16 @@ public static Provisioner fromProject(Project project) {
Dependency[] deps = mavenCoords.stream()
.map(project.getBuildscript().getDependencies()::create)
.toArray(Dependency[]::new);
Configuration config = project.getBuildscript().getConfigurations().detachedConfiguration(deps);
Configuration config = project.getRootProject().getBuildscript().getConfigurations().detachedConfiguration(deps);
config.setDescription(mavenCoords.toString());
return config.resolve();
} catch (Exception e) {
logger.log(Level.SEVERE, "You probably need to add a repository containing the '" + mavenCoords + "' artifact, e.g.: 'buildscript { repositories { mavenCentral() }}'", e);
logger.log(Level.SEVERE,
StringPrinter.buildStringFromLines("You probably need to add a repository containing the '" + mavenCoords + "' artifact in the 'build.gradle' of your root project.",
"E.g.: 'buildscript { repositories { mavenCentral() }}'",
"Note that included buildscripts (using 'apply from') do not share their buildscript repositories with the underlying project.",
"You have to specify the missing repository explicitly in the buildscript of the root project."),
e);
throw e;
}
};
Expand Down