From 3bbf59cb3e080b9abcdf82d1c82e36337ea01ed1 Mon Sep 17 00:00:00 2001 From: Rene Groeschke Date: Sat, 21 Nov 2015 21:16:18 +0000 Subject: simplify implementation and remove use of internal api that is shaded by classloader --- .../groovy/frege/gradle/plugins/FregeRuntime.java | 63 ---------------------- 1 file changed, 63 deletions(-) delete mode 100644 src/main/groovy/frege/gradle/plugins/FregeRuntime.java (limited to 'src/main/groovy/frege/gradle/plugins/FregeRuntime.java') diff --git a/src/main/groovy/frege/gradle/plugins/FregeRuntime.java b/src/main/groovy/frege/gradle/plugins/FregeRuntime.java deleted file mode 100644 index 4265d0b..0000000 --- a/src/main/groovy/frege/gradle/plugins/FregeRuntime.java +++ /dev/null @@ -1,63 +0,0 @@ -package frege.gradle.plugins; - -import com.google.common.collect.Lists; -import org.gradle.api.Buildable; -import org.gradle.api.GradleException; -import org.gradle.api.Project; -import org.gradle.api.artifacts.Dependency; -import org.gradle.api.file.FileCollection; -import org.gradle.api.internal.file.collections.LazilyInitializedFileCollection; -import org.gradle.api.internal.tasks.TaskDependencyResolveContext; - -import java.io.File; -import java.util.List; - -public class FregeRuntime { - - private final Project project; - - public FregeRuntime(Project project) { - this.project = project; - } - - - public FileCollection inferFregeClasspath(final Iterable classpath) { - return new LazilyInitializedFileCollection() { - public String getDisplayName() { - return "Frege runtime classpath"; - } - - public FileCollection createDelegate() { - final FregeJarFile fregeJar = FregeRuntime.this.findFregeJarFile(classpath); - if (fregeJar == null) { - throw new GradleException(String.format("Cannot infer Frege class path because no Frege Jar was found on class path: %s", classpath)); - } - String notation = fregeJar.getDependencyNotation(); - List dependencies = Lists.newArrayList(); - dependencies.add(project.getDependencies().create(notation)); - return project.getConfigurations().detachedConfiguration(dependencies.toArray(new Dependency[dependencies.size()])); - } - - public void visitDependencies(TaskDependencyResolveContext context) { - if (classpath instanceof Buildable) { - context.add(classpath); - } - } - - }; - } - - private FregeJarFile findFregeJarFile(Iterable classpath) { - if (classpath == null) { - return null; - } - for (File file : classpath) { - FregeJarFile fregeJar = FregeJarFile.parse(file); - if (fregeJar != null) { - return fregeJar; - } - } - return null; - } - -} -- cgit