Skip to content
Permalink
Browse files

feat: prefer build.gradle if kotlin also found

  • Loading branch information
lili2311 committed Aug 13, 2020
1 parent 57d8d02 commit 6e806fb1f2971f564befc2db8d18dd380e4787e1
@@ -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;
}
@@ -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');

Empty file.
@@ -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<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}

tasks.withType<Test> {
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")
}
}

0 comments on commit 6e806fb

Please sign in to comment.
You can’t perform that action at this time.