Skip to content

Commit 8a95080

Browse files
committed
Clean unused utility functions
1 parent 2470de0 commit 8a95080

File tree

1 file changed

+23
-60
lines changed

1 file changed

+23
-60
lines changed
Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import org.gradle.api.Action
21
import org.gradle.api.Project
32
import org.gradle.api.artifacts.dsl.RepositoryHandler
4-
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
53
import org.gradle.api.file.DirectoryProperty
64
import org.gradle.api.tasks.compile.AbstractCompile
75
import org.gradle.kotlin.dsl.withGroovyBuilder
@@ -12,32 +10,26 @@ import java.time.format.DateTimeFormatter
1210

1311
/* RepositoryHandler */
1412

15-
fun RepositoryHandler.jitpack() =
16-
this.maven(object: Action<MavenArtifactRepository> {
17-
override fun execute(repo: MavenArtifactRepository) {
18-
repo.setUrl("https://jitpack.io")
19-
}
20-
})
13+
fun RepositoryHandler.jitpack() = maven {
14+
setUrl("https://jitpack.io")
15+
}
2116

22-
fun RepositoryHandler.sonatypeSnapshots() =
23-
this.maven(object: Action<MavenArtifactRepository> {
24-
override fun execute(repo: MavenArtifactRepository) {
25-
repo.setUrl("https://oss.sonatype.org/content/repositories/snapshots")
26-
}
27-
})
17+
fun RepositoryHandler.sonatypeSnapshots() = maven {
18+
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
19+
}
2820

2921
/* Project */
3022

3123
fun Project.fixCompileTaskChain() {
32-
setupCompileChain(
33-
sourceCompileName = "compileKotlin",
34-
targetCompileName = "compileGroovy"
35-
)
36-
37-
setupCompileChain(
38-
sourceCompileName = "compileTestKotlin",
39-
targetCompileName = "compileTestGroovy"
40-
)
24+
setupCompileChain(
25+
sourceCompileName = "compileKotlin",
26+
targetCompileName = "compileGroovy"
27+
)
28+
29+
setupCompileChain(
30+
sourceCompileName = "compileTestKotlin",
31+
targetCompileName = "compileTestGroovy"
32+
)
4133
}
4234

4335
/**
@@ -48,41 +40,12 @@ private fun Project.setupCompileChain(
4840
sourceCompileName: String,
4941
targetCompileName: String
5042
) {
51-
val targetCompile = tasks.getByName(targetCompileName) as AbstractCompile
52-
val sourceCompile = tasks.getByName(sourceCompileName)
53-
54-
// Allow calling the source language's classes from the target language.
55-
// In this case, we allow calling Kotlin from Groovy - it has to be noted however,
56-
// that the other way does not work!
57-
val sourceDir = sourceCompile.withGroovyBuilder { getProperty("destinationDirectory") } as DirectoryProperty
58-
targetCompile.classpath += project.files(sourceDir.get().asFile)
59-
}
60-
61-
/**
62-
* Provides a dependency object to the JUnit 5 plugin, if any can be found.
63-
* This will look in the build folder of the sibling project to try and find
64-
* a previously built "fat JAR", and return it in a format
65-
* compatible to the Gradle dependency mechanism. If no file can be found,
66-
* this method returns null instead.
67-
*/
68-
fun Project.findLocalPluginJar(): File? {
69-
val localLibsFolder = rootDir.parentFile.toPath()
70-
.resolve("plugin/android-junit5/build/libs")
71-
.toFile()
72-
73-
val localPluginJar = (localLibsFolder.listFiles() ?: emptyArray<File>())
74-
.sortedByDescending(File::lastModified)
75-
.firstOrNull { "fat" in it.name && "javadoc" !in it.name && "sources" !in it.name }
76-
77-
return localPluginJar
43+
val targetCompile = tasks.getByName(targetCompileName) as AbstractCompile
44+
val sourceCompile = tasks.getByName(sourceCompileName)
45+
46+
// Allow calling the source language's classes from the target language.
47+
// In this case, we allow calling Kotlin from Groovy - it has to be noted however,
48+
// that the other way does not work!
49+
val sourceDir = sourceCompile.withGroovyBuilder { getProperty("destinationDirectory") } as DirectoryProperty
50+
targetCompile.classpath += project.files(sourceDir.get().asFile)
7851
}
79-
80-
/* File */
81-
82-
/**
83-
* Format the "last modified" timestamp of a file into a human readable string.
84-
*/
85-
fun File.lastModifiedDate(): String =
86-
Instant.ofEpochMilli(lastModified())
87-
.atZone(ZoneId.systemDefault())
88-
.format(DateTimeFormatter.ISO_DATE_TIME)

0 commit comments

Comments
 (0)