diff --git a/src/lib/find-files.ts b/src/lib/find-files.ts index 1f66b65b373..01bf502834f 100644 --- a/src/lib/find-files.ts +++ b/src/lib/find-files.ts @@ -256,6 +256,15 @@ function chooseBestManifest( )[0]; return defaultManifest.path; } + case 'gradle': { + debug( + 'Encountered multiple gradle manifest files, defaulting to build.gradle', + ); + const defaultManifest = files.filter((path) => + ['build.gradle'].includes(path.base), + )[0]; + return defaultManifest.path; + } default: { return null; } diff --git a/test/find-files.test.ts b/test/find-files.test.ts index ca6e2877ec5..052f30db080 100644 --- a/test/find-files.test.ts +++ b/test/find-files.test.ts @@ -21,6 +21,7 @@ test('find all files in test fixture', async (t) => { path.join(testFixture, 'golang', 'golang-gomodules', 'go.mod'), path.join(testFixture, 'gradle', 'build.gradle'), path.join(testFixture, 'gradle-kts', 'build.gradle.kts'), + path.join(testFixture, 'gradle-and-kotlin', 'build.gradle'), path.join(testFixture, 'gradle-multiple', 'gradle/build.gradle'), path.join(testFixture, 'gradle-multiple', 'gradle-another/build.gradle'), path.join(testFixture, 'maven', 'pom.xml'), @@ -54,6 +55,7 @@ test('find all files in test fixture ignoring node_modules', async (t) => { path.join(testFixture, 'golang', 'golang-gomodules', 'go.mod'), path.join(testFixture, 'gradle', 'build.gradle'), path.join(testFixture, 'gradle-kts', 'build.gradle.kts'), + path.join(testFixture, 'gradle-and-kotlin', 'build.gradle'), path.join(testFixture, 'gradle-multiple', 'gradle/build.gradle'), path.join(testFixture, 'gradle-multiple', 'gradle-another/build.gradle'), path.join(testFixture, 'maven', 'pom.xml'), @@ -102,6 +104,19 @@ test('find package-lock.json file in test fixture (ignore package.json in the sa t.same(result, expected, 'should return expected file'); }); +test('find build.gradle file in test fixture (ignore build.gradle in the same folder)', async (t) => { + const buildGradle = path.join(testFixture, 'gradle-and-kotlin'); + + const result = await find( + buildGradle, + [], + ['build.gradle.kts', 'build.gradle'], + 1, + ); + const expected = [path.join(buildGradle, 'build.gradle')]; + t.same(result, expected, 'should return expected file'); +}); + test('find Gemfile.lock file in test fixture (ignore Gemfile in the same folder)', async (t) => { const npmLockfilePath = path.join(testFixture, 'ruby'); diff --git a/test/fixtures/find-files/gradle-and-kotlin/build.gradle b/test/fixtures/find-files/gradle-and-kotlin/build.gradle new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/fixtures/find-files/gradle-and-kotlin/build.gradle.kts b/test/fixtures/find-files/gradle-and-kotlin/build.gradle.kts new file mode 100644 index 00000000000..545523eb6cc --- /dev/null +++ b/test/fixtures/find-files/gradle-and-kotlin/build.gradle.kts @@ -0,0 +1,33 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + val kotlinVersion = "1.3.21" + id("org.jetbrains.kotlin.jvm") version kotlinVersion + id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion + id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion +} + +version = "1.0.0-SNAPSHOT" + +tasks.withType { + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs = listOf("-Xjsr305=strict") + } +} + +tasks.withType { + useJUnitPlatform() +} + +repositories { + mavenCentral() +} + +dependencies { + // Removed Spring because too heavy + compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + testCompile("org.jetbrains.kotlin:kotlin-reflect") { + exclude(module = "junit") + } +}