aboutsummaryrefslogtreecommitdiff
path: root/src/main/groovy/frege/gradle
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/groovy/frege/gradle')
-rw-r--r--src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java19
-rw-r--r--src/main/groovy/frege/gradle/plugins/FregeJarFile.java34
-rw-r--r--src/main/groovy/frege/gradle/plugins/FregeRuntime.java63
-rw-r--r--src/main/groovy/frege/gradle/tasks/FregeCompile.groovy3
4 files changed, 2 insertions, 117 deletions
diff --git a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
index 8bf5399..9f8ebd9 100644
--- a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
+++ b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java
@@ -15,7 +15,6 @@ import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.SourceSet;
import javax.inject.Inject;
-import java.util.concurrent.Callable;
public class FregeBasePlugin implements Plugin<Project> {
private FileResolver fileResolver;
@@ -30,15 +29,13 @@ public class FregeBasePlugin implements Plugin<Project> {
}
@Override
- public void apply(Project project) {
+ public void apply(final Project project) {
// Workaround to build proper jars on Windows, see https://github.com/Frege/frege-gradle-plugin/issues/9
this.project = project;
System.setProperty("file.encoding", "UTF-8");
project.getPluginManager().apply(JavaBasePlugin.class);
fregePluginExtension = project.getExtensions().create(EXTENSION_NAME, FregePluginExtension.class);
JavaBasePlugin javaBasePlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
-
- configureCompileDefaults(new FregeRuntime(project));
configureSourceSetDefaults(javaBasePlugin);
}
@@ -70,18 +67,4 @@ public class FregeBasePlugin implements Plugin<Project> {
}
});
}
-
- private void configureCompileDefaults(final FregeRuntime fregeRuntime) {
- this.project.getTasks().withType(FregeCompile.class, new Action<FregeCompile>() {
- public void execute(final FregeCompile compile) {
- compile.getConventionMapping().map("fregeClasspath", new Callable() {
- public Object call() throws Exception {
- return fregeRuntime.inferFregeClasspath(compile.getClasspath());
- }
-
- });
- }
- });
- }
-
}
diff --git a/src/main/groovy/frege/gradle/plugins/FregeJarFile.java b/src/main/groovy/frege/gradle/plugins/FregeJarFile.java
deleted file mode 100644
index eaf7d8f..0000000
--- a/src/main/groovy/frege/gradle/plugins/FregeJarFile.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package frege.gradle.plugins;
-
-import org.gradle.util.VersionNumber;
-
-import java.io.File;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class FregeJarFile {
- private static final Pattern FILE_NAME_PATTERN = Pattern.compile("(frege(?:-all)?)-(\\d.*?)(-indy)?.jar");
- private final File file;
- private final Matcher matcher;
- private String version;
-
- private FregeJarFile(File file, Matcher matcher) {
- this.file = file;
- this.matcher = matcher;
- }
-
-
- public static FregeJarFile parse(File file) {
- Matcher matcher = FILE_NAME_PATTERN.matcher(file.getName());
- return matcher.matches() ? new FregeJarFile(file, matcher) : null;
- }
-
- public String getDependencyNotation() {
- return "org.frege-lang:frege:" + getVersion();
-
- }
-
- public VersionNumber getVersion() {
- return VersionNumber.parse(matcher.group(2));
- }
-}
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<File> 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<Dependency> 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<File> classpath) {
- if (classpath == null) {
- return null;
- }
- for (File file : classpath) {
- FregeJarFile fregeJar = FregeJarFile.parse(file);
- if (fregeJar != null) {
- return fregeJar;
- }
- }
- return null;
- }
-
-}
diff --git a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy
index d39f15f..3da2b34 100644
--- a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy
+++ b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy
@@ -11,7 +11,6 @@ import org.gradle.process.JavaExecSpec
@TypeChecked
class FregeCompile extends AbstractCompile {
- FileCollection fregeClasspath
FileCollection classpath
@Input
@@ -89,7 +88,7 @@ class FregeCompile extends AbstractCompile {
@Override
void execute(JavaExecSpec javaExecSpec) {
javaExecSpec.args = compilerArgs
- javaExecSpec.classpath = FregeCompile.this.classpath + FregeCompile.this.fregeClasspath
+ javaExecSpec.classpath = FregeCompile.this.classpath
javaExecSpec.main = mainClass
}
});