-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build: Fail if any libs depend on non-core libs (#29336)
Fails the build if any subprojects of `:libs` have dependencies in `:libs` except for `:libs:elasticsearch-core`. Since we now have three places where we resolve project substitutions I've added `dependencyToProject` to `project.ext` in all projects. It resolves both `project` style dependencies and "external" style (like "org.elasticsearch:elasticsearch-core:${version}") dependencies to `Project`s using the `projectSubstitutions`. I use this new function all three places where resovle project substitutions. Finally this pulls `apply plugin: 'elasticsearch.build'` out of `libs/*/build.gradle` and into a subprojects clause in `libs/build.gradle`. I do this entirely so that I can call `tasks.precommit.dependsOn checkDependencies` without waiting for the subprojects to be evaluated or worrying about whether or not they have `precommit` set up in a normal way.
- Loading branch information
Showing
6 changed files
with
68 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch 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. | ||
*/ | ||
|
||
subprojects { | ||
/* | ||
* All subprojects are java projects using Elasticsearch's standard build | ||
* tools. | ||
*/ | ||
apply plugin: 'elasticsearch.build' | ||
|
||
/* | ||
* Subprojects may depend on the "core" lib but may not depend on any | ||
* other libs. This keeps are dependencies simpler. | ||
*/ | ||
project.afterEvaluate { | ||
configurations.all { Configuration conf -> | ||
dependencies.all { Dependency dep -> | ||
Project depProject = dependencyToProject(dep) | ||
if (depProject != null | ||
&& false == depProject.path.equals(':libs:elasticsearch-core') | ||
&& depProject.path.startsWith(':libs')) { | ||
throw new InvalidUserDataException("projects in :libs " | ||
+ "may not depend on other projects libs except " | ||
+ ":libs:elasticsearch-core but " | ||
+ "${project.path} depends on ${depProject.path}") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters