mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Gradle: use CompileStatic for SourceSetCachedFinder
This commit is contained in:
+22
-9
@@ -15,28 +15,33 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.tooling.util
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 5/19/2016
|
||||
*/
|
||||
@CompileStatic
|
||||
class SourceSetCachedFinder {
|
||||
private final myArtifactsMap = new HashMap<String, SourceSet>()
|
||||
private final Map<String, SourceSet> myArtifactsMap = new HashMap<String, SourceSet>()
|
||||
|
||||
@SuppressWarnings("GrUnresolvedAccess")
|
||||
SourceSetCachedFinder(@NotNull Project project) {
|
||||
def rootProject = project.rootProject
|
||||
rootProject.subprojects.each { Project p ->
|
||||
if (p.hasProperty("sourceSets") && (p.sourceSets instanceof SourceSetContainer)) {
|
||||
p.sourceSets.each { SourceSet sourceSet ->
|
||||
def jarTask = p.tasks.findByName(sourceSet.getJarTaskName())
|
||||
def file = jarTask?.archivePath as File
|
||||
if (file) {
|
||||
myArtifactsMap[file.path] = sourceSet
|
||||
for (Project p : rootProject.subprojects) {
|
||||
getSourceSetContainer(p)?.each { SourceSet sourceSet ->
|
||||
def task = p.tasks.findByName(sourceSet.getJarTaskName())
|
||||
if (task instanceof AbstractArchiveTask) {
|
||||
AbstractArchiveTask jarTask = (AbstractArchiveTask)task
|
||||
def archivePath = jarTask?.getArchivePath()
|
||||
if (archivePath) {
|
||||
myArtifactsMap[archivePath.path] = sourceSet
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +49,14 @@ class SourceSetCachedFinder {
|
||||
}
|
||||
|
||||
SourceSet findByArtifact(String artifactPath) {
|
||||
return myArtifactsMap[artifactPath]
|
||||
myArtifactsMap[artifactPath]
|
||||
}
|
||||
|
||||
static JavaPluginConvention getJavaPluginConvention(Project p) {
|
||||
p.convention.findPlugin(JavaPluginConvention)
|
||||
}
|
||||
|
||||
static SourceSetContainer getSourceSetContainer(Project p) {
|
||||
getJavaPluginConvention(p)?.sourceSets
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user