mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Gradle] do not import buildSrc project if it was included into the main build IDEA-228368
GitOrigin-RevId: e5a8c55d51e7fa8727b11b5b3c715c600f05dfa6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
336042ac45
commit
1b3c0ed52f
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.gradle.importing
|
||||
|
||||
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
|
||||
import org.junit.Test
|
||||
|
||||
class GradleBuildSrcImportingTest : GradleImportingTestCase() {
|
||||
@@ -21,4 +22,20 @@ class GradleBuildSrcImportingTest : GradleImportingTestCase() {
|
||||
assertModules("project", "project.main", "project.test",
|
||||
"project.buildSrc", "project.buildSrc.main", "project.buildSrc.test")
|
||||
}
|
||||
|
||||
@TargetVersions("<6.0") // since 6.9 'buildSrc' is a reserved project name, https://docs.gradle.org/current/userguide/upgrading_version_5.html#buildsrc_is_now_reserved_as_a_project_and_subproject_build_name
|
||||
@Test
|
||||
fun `test buildSrc project is included into the main build`() {
|
||||
createProjectSubFile("buildSrc/src/main/java/my/pack/Util.java",
|
||||
"package my.pack;\npublic class Util {}")
|
||||
|
||||
importProject("apply plugin: 'java'")
|
||||
assertModules("project", "project.main", "project.test",
|
||||
"project.buildSrc", "project.buildSrc.main", "project.buildSrc.test")
|
||||
|
||||
createSettingsFile("include 'buildSrc'")
|
||||
importProject("apply plugin: 'java'")
|
||||
assertModules("project", "project.main", "project.test", "project.buildSrc")
|
||||
|
||||
}
|
||||
}
|
||||
+5
@@ -170,6 +170,11 @@ public class GradleBuildSrcProjectsResolver {
|
||||
return;
|
||||
}
|
||||
|
||||
if (includedModulesPaths.containsKey(projectPath)) {
|
||||
// `buildSrc` has been already included into the main build (prohibited since 6.0, https://docs.gradle.org/current/userguide/upgrading_version_5.html#buildsrc_is_now_reserved_as_a_project_and_subproject_build_name)
|
||||
return;
|
||||
}
|
||||
|
||||
if (ArrayUtil.isEmpty(projectPathFile.list((dir, name) -> !name.equals(".gradle") && !name.equals("build")))) {
|
||||
return;
|
||||
}
|
||||
|
||||
+11
-1
@@ -35,7 +35,7 @@ public class VersionMatcher {
|
||||
}
|
||||
|
||||
public boolean isVersionMatch(@Nullable TargetVersions targetVersions) {
|
||||
if (targetVersions == null || targetVersions.value() == null || targetVersions.value().isEmpty()) return true;
|
||||
if (targetVersions == null || targetVersions.value().isEmpty()) return true;
|
||||
|
||||
final GradleVersion current = adjust(myGradleVersion, targetVersions.checkBaseVersions());
|
||||
|
||||
@@ -43,6 +43,16 @@ public class VersionMatcher {
|
||||
String minVersion = targetVersions.value().substring(0, targetVersions.value().length() - 1);
|
||||
return compare(current, minVersion, targetVersions.checkBaseVersions()) >= 0;
|
||||
}
|
||||
else if (targetVersions.value().startsWith("<")) {
|
||||
if (targetVersions.value().startsWith("<=")) {
|
||||
String maxVersion = targetVersions.value().substring(2);
|
||||
return compare(current, maxVersion, targetVersions.checkBaseVersions()) <= 0;
|
||||
}
|
||||
else {
|
||||
String maxVersion = targetVersions.value().substring(1);
|
||||
return compare(current, maxVersion, targetVersions.checkBaseVersions()) < 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
final int rangeIndex = targetVersions.value().indexOf(RANGE_TOKEN);
|
||||
if (rangeIndex != -1) {
|
||||
|
||||
Reference in New Issue
Block a user