├── todo.txt ├── docs └── img │ ├── FileTypes.png │ ├── external_tool_run.png │ ├── Frege_Gradle_Tasks.png │ ├── external_tool_frepl.png │ ├── external_tool_test.png │ └── watcher_fregeCompile.png ├── lib └── frege-3.25.84.jar ├── src ├── main │ ├── resources │ │ └── META-INF │ │ │ └── gradle-plugins │ │ │ ├── org.frege-lang.properties │ │ │ └── org.frege-lang.base.properties │ └── groovy │ │ └── frege │ │ └── gradle │ │ ├── FregeSourceSetOutputs.groovy │ │ ├── plugins │ │ ├── FregePluginExtension.groovy │ │ ├── FregePlugin.groovy │ │ └── FregeBasePlugin.java │ │ ├── FregeSourceSet.java │ │ ├── FregeSourceDirectorySet.groovy │ │ ├── DefaultFregeSourceSet.java │ │ ├── FregeSourceSetDirectoryFactory.groovy │ │ └── tasks │ │ ├── FregeRepl.groovy │ │ ├── FregeNativeGen.groovy │ │ ├── FregeDoc.groovy │ │ ├── FregeQuickCheck.groovy │ │ └── FregeCompile.groovy ├── test │ └── groovy │ │ └── frege │ │ └── gradle │ │ ├── plugins │ │ ├── FregeBasePluginTest.groovy │ │ └── FregePluginTest.groovy │ │ └── tasks │ │ └── FregeCompileTest.groovy └── integTest │ └── groovy │ └── frege │ └── gradle │ ├── integtest │ └── fixtures │ │ └── AbstractFregeIntegrationSpec.groovy │ ├── tasks │ └── FregeCompileIntegTest.groovy │ └── plugins │ └── FregePluginIntegTest.groovy ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── integTest.gradle └── sonatype.gradle ├── gradle.properties ├── deploy.sh ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.adoc ├── gradlew.bat └── gradlew /todo.txt: -------------------------------------------------------------------------------- 1 | - make a compileTestFrege with the respective task dependencies 2 | -------------------------------------------------------------------------------- /docs/img/FileTypes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/FileTypes.png -------------------------------------------------------------------------------- /lib/frege-3.25.84.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/lib/frege-3.25.84.jar -------------------------------------------------------------------------------- /docs/img/external_tool_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/external_tool_run.png -------------------------------------------------------------------------------- /docs/img/Frege_Gradle_Tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/Frege_Gradle_Tasks.png -------------------------------------------------------------------------------- /docs/img/external_tool_frepl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/external_tool_frepl.png -------------------------------------------------------------------------------- /docs/img/external_tool_test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/external_tool_test.png -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/org.frege-lang.properties: -------------------------------------------------------------------------------- 1 | implementation-class=frege.gradle.plugins.FregePlugin 2 | -------------------------------------------------------------------------------- /docs/img/watcher_fregeCompile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/docs/img/watcher_fregeCompile.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Frege/frege-gradle-plugin/master/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/org.frege-lang.base.properties: -------------------------------------------------------------------------------- 1 | implementation-class=frege.gradle.plugins.FregeBasePlugin 2 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle 2 | 3 | import org.gradle.api.file.FileCollection 4 | 5 | interface FregeSourceSetOutputs { 6 | FileCollection getDirs() 7 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | #currently not needed 2 | 3 | signingEnabled = false 4 | sonatypeUsername = incorrectUsername 5 | sonatypePassword = incorrectPassword 6 | 7 | #(all,none,summary) 8 | org.gradle.warning.mode=all 9 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/plugins/FregePluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins 2 | 3 | /** 4 | * Created by mperry on 6/02/2015. 5 | */ 6 | class FregePluginExtension { 7 | 8 | 9 | String key1 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/FregeSourceSet.java: -------------------------------------------------------------------------------- 1 | package frege.gradle; 2 | 3 | import org.gradle.api.file.SourceDirectorySet; 4 | 5 | public interface FregeSourceSet { 6 | SourceDirectorySet getFrege(); 7 | SourceDirectorySet getAllFrege(); 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 23 13:39:19 CEST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./gradlew uploadArchives -PsonatypeUsername="${SONATYPE_USERNAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" -i -s 4 | RETVAL=$? 5 | 6 | if [ $RETVAL -eq 0 ]; then 7 | echo 'Completed publish!' 8 | else 9 | echo 'Publish failed.' 10 | return 1 11 | fi 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # ignore IDEA files 3 | *.iml 4 | *.ipr 5 | *.iws 6 | .idea 7 | # ignore eclipse files 8 | .project 9 | .classpath 10 | .settings 11 | .scala_dependencies 12 | .externalToolBuilders 13 | .factorypath 14 | # ignore others 15 | out 16 | src/test/mod-test 17 | classes 18 | .cache 19 | .DS_Store 20 | .gradle 21 | .springBeans 22 | bin 23 | build 24 | *.pyc 25 | 26 | # Ignore Gradle GUI config 27 | gradle-app.setting 28 | 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | sudo: false 5 | env: 6 | global: 7 | - secure: WXBVeS+6GtKNpQnmc00bOEVNRMOsADjg6XRd/PeZMa7IpYBE6HyaIOT/LocJ5J9p3lE6vmNM2kreHjUn6pPk6N3jcT9stbeNSbUFAY52WhmyS9Hq/5qGyuw2rAI+nAVL/yG71HWQsdyrYNjJDMq/CduHf67Gqkn64ihWC4yjr6I= 8 | - secure: RxhrCcuwVLvHdzw0eKE9vxA8rRMs+ZJ+uHu8//YsproWV03FYvit7KwjwvAe8QkLJXl4ePI8XuycTc/xONGqUca0kQ5sO+0ZUytbKKDDWxJ2bE/O741z5TS0ZDypcLwk6BfQyHBEHbd8szsNhe/x3a5kwBE43d5zKI0KCSGJLrU= 9 | after_success: 10 | - chmod +x ./deploy.sh; ./deploy.sh 11 | before_script: 12 | - echo "U=$SONATYPE_USERNAME" 13 | - echo "P=$SONATYPE_PASSWORD" 14 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle 2 | 3 | import org.gradle.api.file.FileTree 4 | import org.gradle.api.tasks.util.PatternFilterable 5 | 6 | interface FregeSourceDirectorySet extends PatternFilterable { 7 | def String getName() 8 | 9 | def FregeSourceDirectorySet srcDir(Object srcPath) 10 | 11 | def FregeSourceDirectorySet srcDirs(Object... srcPaths) 12 | 13 | def Set getSrcDirs() 14 | 15 | def FregeSourceDirectorySet setSrcDirs(Iterable srcPaths) 16 | 17 | def FileTree getFiles() 18 | 19 | def PatternFilterable getFilter() 20 | 21 | def FregeSourceSetOutputs getOutput() 22 | 23 | def String getGeneratorTaskName() 24 | 25 | boolean contains(File file) 26 | } -------------------------------------------------------------------------------- /src/test/groovy/frege/gradle/plugins/FregeBasePluginTest.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import spock.lang.Specification 6 | 7 | public class FregeBasePluginTest extends Specification { 8 | 9 | Project project = ProjectBuilder.builder().build() 10 | 11 | def setup(){ 12 | when: 13 | project.plugins.apply(FregeBasePlugin) 14 | } 15 | 16 | def "adds frege extension"(){ 17 | expect: 18 | project.getExtensions().getByName(FregeBasePlugin.EXTENSION_NAME) != null 19 | } 20 | 21 | def "applies java base plugin"(){ 22 | expect: 23 | project.pluginManager.hasPlugin("java-base") 24 | } 25 | 26 | def "can be identified by id"(){ 27 | expect: 28 | project.pluginManager.hasPlugin("org.frege-lang.base") 29 | } 30 | } -------------------------------------------------------------------------------- /src/test/groovy/frege/gradle/plugins/FregePluginTest.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins 2 | import org.gradle.api.Project 3 | import org.gradle.testfixtures.ProjectBuilder 4 | import spock.lang.Specification 5 | import spock.lang.Unroll 6 | 7 | class FregePluginTest extends Specification { 8 | 9 | Project project = ProjectBuilder.builder().build() 10 | 11 | def setup(){ 12 | when: 13 | project.plugins.apply(FregePlugin) 14 | } 15 | 16 | def "applies frege base plugin"() { 17 | expect: 18 | project.pluginManager.findPlugin("org.frege-lang.base") != null 19 | } 20 | 21 | def "can be identified by id"(){ 22 | expect: 23 | project.pluginManager.hasPlugin("org.frege-lang") 24 | } 25 | 26 | @Unroll 27 | def "adds #fregeTaskName task"(){ 28 | when: 29 | def fregeTask = project.tasks.findByName(fregeTaskName) 30 | then: 31 | fregeTask != null 32 | fregeTask.group == "frege" 33 | where: 34 | fregeTaskName << ["fregeRepl", "fregeDoc", "fregeQuickCheck", "fregeNativeGen"] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/groovy/frege/gradle/tasks/FregeCompileTest.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import spock.lang.Specification 6 | 7 | class FregeCompileTest extends Specification { 8 | Project project = ProjectBuilder.builder().build() 9 | FregeCompile compile 10 | 11 | def setup() { 12 | when: 13 | compile = project.tasks.create("fregeCompile", FregeCompile) 14 | } 15 | 16 | 17 | def "configured sourcePaths tracked"() { 18 | when: 19 | compile.source("someFolder") 20 | then: 21 | compile.sourcePaths == [project.file("someFolder")] 22 | } 23 | 24 | 25 | def "default assembleArguments"() { 26 | given: 27 | compile.destinationDir = project.file("testoutput") 28 | expect: 29 | compile.assembleArguments() == ["-inline", "-make", "-d", project.file("testoutput").absolutePath] 30 | } 31 | 32 | def "with prefix"() { 33 | given: 34 | compile.destinationDir = project.file("testoutput") 35 | compile.prefix = "somePrefix" 36 | expect: 37 | compile.assembleArguments() == ["-inline", "-make", "-prefix", "somePrefix", "-d", project.file("testoutput").absolutePath] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/DefaultFregeSourceSet.java: -------------------------------------------------------------------------------- 1 | package frege.gradle; 2 | 3 | import groovy.lang.Closure; 4 | import org.gradle.api.file.SourceDirectorySet; 5 | import org.gradle.util.ConfigureUtil; 6 | 7 | public class DefaultFregeSourceSet implements FregeSourceSet { 8 | private final SourceDirectorySet frege; 9 | private final SourceDirectorySet allFrege; 10 | 11 | public DefaultFregeSourceSet(String displayName, FregeSourceSetDirectoryFactory sourceSetFactory) { 12 | this.frege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); 13 | this.frege.getFilter().include(new String[]{"**/*.fr"}); 14 | this.allFrege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); 15 | this.allFrege.source(this.frege); 16 | this.allFrege.getFilter().include(new String[]{"**/*.fr"}); 17 | } 18 | 19 | public SourceDirectorySet getFrege() { 20 | return this.frege; 21 | } 22 | 23 | public FregeSourceSet frege(Closure configureClosure) { 24 | ConfigureUtil.configure(configureClosure, this.getFrege()); 25 | return this; 26 | } 27 | 28 | public SourceDirectorySet getAllFrege() { 29 | return this.allFrege; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle 2 | 3 | import org.gradle.api.file.SourceDirectorySet 4 | import org.gradle.api.internal.file.DefaultSourceDirectorySet 5 | import org.gradle.api.internal.file.FileResolver 6 | import org.gradle.api.internal.file.SourceDirectorySetFactory 7 | import org.gradle.api.internal.project.ProjectInternal 8 | import org.gradle.util.GradleVersion 9 | 10 | public class FregeSourceSetDirectoryFactory { 11 | private final boolean useFactory; 12 | private final FileResolver fileResolver 13 | private final ProjectInternal project 14 | 15 | public FregeSourceSetDirectoryFactory(ProjectInternal project, FileResolver fileResolver) { 16 | this.fileResolver = fileResolver 17 | this.project = project 18 | this.useFactory = GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0; 19 | 20 | } 21 | 22 | public SourceDirectorySet newSourceSetDirectory(String displayName) { 23 | if (useFactory) { 24 | SourceDirectorySetFactory factory = project.getServices().get(SourceDirectorySetFactory.class); 25 | return factory.create(displayName); 26 | } else { 27 | return new DefaultSourceDirectorySet(displayName, fileResolver); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gradle/integTest.gradle: -------------------------------------------------------------------------------- 1 | sourceSets { 2 | integTest { 3 | compileClasspath += main.output + test.output 4 | runtimeClasspath += main.output + test.output 5 | } 6 | } 7 | 8 | configurations { 9 | integTestCompile.extendsFrom testCompile 10 | integTestRuntime.extendsFrom testRuntime 11 | } 12 | 13 | task integTest(type: Test) { 14 | shouldRunAfter 'test' 15 | testClassesDirs = sourceSets.integTest.output.classesDirs 16 | classpath = sourceSets.integTest.runtimeClasspath 17 | } 18 | 19 | check.dependsOn(integTest) 20 | 21 | plugins.withType(org.gradle.plugins.ide.idea.IdeaPlugin) { 22 | idea { 23 | module { 24 | testSourceDirs += sourceSets.integTest.groovy.srcDirs 25 | testSourceDirs += sourceSets.integTest.resources.srcDirs 26 | scopes.TEST.plus.add(configurations.integTestCompile) 27 | scopes.TEST.plus.add(configurations.integTestRuntime) 28 | } 29 | } 30 | } 31 | 32 | 33 | task createClasspathManifest { 34 | def outputDir = file("$buildDir/$name") 35 | 36 | inputs.files sourceSets.main.runtimeClasspath 37 | outputs.dir outputDir 38 | 39 | doLast { 40 | outputDir.mkdirs() 41 | file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n") 42 | } 43 | } 44 | 45 | dependencies { 46 | testRuntimeOnly files(createClasspathManifest) 47 | // integTestRuntime files(createClasspathManifest) // old 48 | } 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Frege 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of frege-gradle-plugin nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/plugins/FregePlugin.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins 2 | import frege.gradle.tasks.FregeDoc 3 | import frege.gradle.tasks.FregeNativeGen 4 | import frege.gradle.tasks.FregeQuickCheck 5 | import frege.gradle.tasks.FregeRepl 6 | import org.gradle.api.Plugin 7 | import org.gradle.api.Project 8 | import org.gradle.api.tasks.SourceSet 9 | 10 | class FregePlugin implements Plugin { 11 | 12 | Project project 13 | 14 | void apply(Project project) { 15 | this.project = project 16 | 17 | project.plugins.apply(FregeBasePlugin) 18 | project.plugins.apply("java") 19 | 20 | def replTask = project.task('fregeRepl', type: FregeRepl, group: 'frege', dependsOn: 'compileFrege') 21 | replTask.outputs.upToDateWhen { false } // always run, regardless of up to date checks 22 | 23 | def checkTask = project.task('fregeQuickCheck', type: FregeQuickCheck, group: 'frege', dependsOn: 'testClasses') 24 | checkTask.outputs.upToDateWhen { false } // always run, regardless of up to date checks 25 | 26 | project.tasks.test.dependsOn("fregeQuickCheck") 27 | 28 | 29 | configureFregeDoc() 30 | 31 | project.task('fregeNativeGen', type: FregeNativeGen, group: 'frege') 32 | 33 | } 34 | 35 | def configureFregeDoc() { 36 | FregeDoc fregeDoc = project.tasks.create('fregeDoc', FregeDoc) 37 | fregeDoc.group = 'frege' 38 | fregeDoc.dependsOn "compileFrege" // TODO remove 39 | SourceSet mainSourceSet = project.sourceSets.main 40 | fregeDoc.module = mainSourceSet.output.classesDirs.first().absolutePath 41 | fregeDoc.classpath = mainSourceSet.runtimeClasspath 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/tasks/FregeRepl.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.internal.file.FileResolver 5 | import org.gradle.api.tasks.* 6 | import org.gradle.process.internal.DefaultExecActionFactory 7 | import org.gradle.process.internal.DefaultJavaExecAction 8 | import org.gradle.process.internal.JavaExecAction 9 | 10 | class FregeRepl extends DefaultTask { 11 | 12 | static String DEFAULT_SRC_DIR = "src/main/frege" // TODO: should this come from a source set? 13 | static String DEFAULT_CLASSES_SUBDIR = "classes/main" // TODO: should this come from a convention? 14 | 15 | @Optional @InputDirectory 16 | File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR).exists() ? new File(project.projectDir, DEFAULT_SRC_DIR) : null 17 | 18 | @Optional @OutputDirectory 19 | File targetDir = new File(project.buildDir, DEFAULT_CLASSES_SUBDIR) 20 | 21 | @TaskAction 22 | void openFregeRepl() { 23 | 24 | if (sourceDir != null && !sourceDir.exists() ) { 25 | def currentDir = new File('.') 26 | logger.info "Intended source dir '${sourceDir.absolutePath}' doesn't exist. Using current dir '${currentDir.absolutePath}' ." 27 | sourceDir = currentDir 28 | } 29 | 30 | FileResolver fileResolver = getServices().get(FileResolver.class) 31 | JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() 32 | action.setMain("frege.repl.FregeRepl") 33 | action.workingDir = sourceDir ?: project.projectDir 34 | action.standardInput = System.in 35 | action.setClasspath(project.files(project.configurations.runtime ) + project.files(targetDir.absolutePath)) 36 | 37 | action.execute() 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.internal.file.FileResolver 5 | import org.gradle.api.tasks.Input 6 | import org.gradle.api.tasks.InputFile 7 | import org.gradle.api.tasks.Optional 8 | import org.gradle.api.tasks.OutputFile 9 | import org.gradle.api.tasks.TaskAction 10 | import org.gradle.process.internal.DefaultExecActionFactory 11 | import org.gradle.process.internal.DefaultJavaExecAction 12 | import org.gradle.process.internal.JavaExecAction 13 | 14 | class FregeNativeGen extends DefaultTask { 15 | 16 | /* 17 | * Example from https://github.com/Frege/frege-native-gen: 18 | * java -cp /path/to/guava-15.0.jar:lib/frege-YY.jar:frege-native-gen-XX.jar frege.nativegen.Main com.google.common.collect.ImmutableCollection 19 | */ 20 | 21 | // help not currently supported by native gen tool 22 | Boolean help = false 23 | 24 | @Optional 25 | @InputFile 26 | File typesFile = new File(project.projectDir, "types.properties") 27 | 28 | @Input 29 | String className = null 30 | 31 | @Optional 32 | @OutputFile 33 | File outputFile = new File(project.buildDir, "generated/frege/NativeGenOutput.fr") 34 | 35 | 36 | @TaskAction 37 | void gen() { 38 | 39 | FileResolver fileResolver = getServices().get(FileResolver.class) 40 | JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() 41 | action.setMain("frege.nativegen.Main") 42 | action.workingDir = project.projectDir 43 | action.standardInput = System.in 44 | action.standardOutput = outputFile.newOutputStream() 45 | action.errorOutput = System.err 46 | action.setClasspath(project.files(project.configurations.compile) + project.files("$project.buildDir/classes/main")) 47 | 48 | def args = [] 49 | if (help) { 50 | args << "-h" 51 | } else { 52 | args << className 53 | args << typesFile.absolutePath 54 | } 55 | logger.info("Calling Frege NativeGen with args: '$args'") 56 | action.args args 57 | action.execute() 58 | } 59 | 60 | 61 | } 62 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | 2 | = Frege Gradle Plugin 3 | 4 | This is the official Gradle plugin to compile Frege projects (https://github.com/Frege/frege). See the example project (https://github.com/mperry/frege-gradle-example) for examples on the usage of this plugin. 5 | 6 | This plugin is an alternative to using Gradle's JavaEx task to start the Frege tools. 7 | Those who prefer the latter might want to have a look at (https://github.com/Dierk/HelloFrege) 8 | 9 | == Plugin Application 10 | 11 | The gradle plugin portal page for Frege documents how to apply the Frege plugin (https://plugins.gradle.org/plugin/org.frege-lang). 12 | 13 | For applying the plugin in all Gradle versions use: 14 | ``` 15 | buildscript { 16 | repositories { 17 | maven { 18 | url "https://plugins.gradle.org/m2/" 19 | } 20 | } 21 | dependencies { 22 | classpath "gradle.plugin.org.frege-lang:frege-gradle-plugin:0.8" 23 | } 24 | } 25 | 26 | apply plugin: "org.frege-lang" 27 | ``` 28 | 29 | To apply the plugin using the new incubating, plugin mechanism (since Gradle 2.1), add: 30 | ``` 31 | plugins { 32 | id "org.frege-lang" version "0.8" 33 | } 34 | ``` 35 | 36 | == Tasks 37 | 38 | This plugin creates the following tasks: 39 | 40 | * fregeRepl 41 | * fregeQuickCheck 42 | * fregeDoc 43 | * fregeNativeGen 44 | * compileFrege 45 | * compileTestFrege 46 | 47 | The plugin adds dependencies so that using the `build` task is typically all that is required to invoke the `compileFrege` and `compileTestFrege` tasks. These task dependencies include: 48 | 49 | * classes -> compileFrege -> compileJava 50 | * testClasses -> compileTestFrege -> compileTestJava 51 | * test -> fregeQuickCheck -> testClasses 52 | 53 | == Task Help 54 | 55 | TODO: Add options and descriptions for each task above. 56 | 57 | == Example 58 | 59 | See: 60 | 61 | * Plugin application: https://plugins.gradle.org/plugin/org.frege-lang 62 | * Plugin usage: https://github.com/mperry/frege-gradle-example 63 | 64 | == Continuous Integration 65 | 66 | The Travis CI build of this repository is at https://travis-ci.org/Frege/frege-gradle-plugin. 67 | 68 | == Snapshots 69 | 70 | Snapshot releases are available from the Sonatype repository at https://oss.sonatype.org/content/groups/public/org/frege-lang. 71 | -------------------------------------------------------------------------------- /src/integTest/groovy/frege/gradle/integtest/fixtures/AbstractFregeIntegrationSpec.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.integtest.fixtures 2 | 3 | import org.gradle.testkit.runner.GradleRunner 4 | import org.gradle.testkit.runner.BuildResult 5 | import org.junit.Rule 6 | import org.junit.rules.TemporaryFolder 7 | import spock.lang.Specification 8 | 9 | class AbstractFregeIntegrationSpec extends Specification { 10 | public static final String DEFAULT_FREGE_VERSION = "3.24.405" 11 | List pluginClasspath 12 | 13 | @Rule 14 | final TemporaryFolder testProjectDir = new TemporaryFolder() 15 | File buildFile 16 | 17 | def setup() { 18 | buildFile = testProjectDir.newFile('build.gradle') 19 | 20 | testProjectDir.newFolder("src", "main", "java", "org", "frege", "java") 21 | testProjectDir.newFolder("src", "main", "frege", "org", "frege") 22 | 23 | def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt") 24 | if (pluginClasspathResource == null) { 25 | // try again via file reference 26 | pluginClasspathResource = new File("build/createClasspathManifest/plugin-classpath.txt") 27 | if (pluginClasspathResource == null) { 28 | throw new IllegalStateException("Did not find plugin classpath resource, run `integTestClasses` build task.") 29 | } 30 | } 31 | pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) } 32 | } 33 | 34 | 35 | BuildResult run(String task) { 36 | run(null, task); 37 | } 38 | 39 | BuildResult run(String gradleVersion, String task) { 40 | def writer = new StringWriter(); 41 | GradleRunner runner = newRunner(task, writer, gradleVersion) 42 | def result = runner.build() 43 | println writer; 44 | return result; 45 | } 46 | 47 | BuildResult fail(String task) { 48 | def writer = new StringWriter(); 49 | GradleRunner runner = newRunner(task, writer, null) 50 | def result = runner.buildAndFail() 51 | println writer; 52 | return result; 53 | } 54 | 55 | private GradleRunner newRunner(String task, StringWriter writer, String gradleVersion) { 56 | def runner = GradleRunner.create() 57 | .withProjectDir(testProjectDir.root) 58 | .withArguments(task) 59 | .withPluginClasspath(pluginClasspath) 60 | .forwardStdOutput(writer) 61 | if (gradleVersion) { 62 | runner.withGradleVersion(gradleVersion) 63 | } 64 | runner 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /gradle/sonatype.gradle: -------------------------------------------------------------------------------- 1 | 2 | ext { 3 | 4 | sonatypeBaseUrl = "https://oss.sonatype.org" 5 | sonatypeSnapshotUrl = "$sonatypeBaseUrl/content/repositories/snapshots/" 6 | sonatypeRepositoryUrl = "$sonatypeBaseUrl/content/groups/public" 7 | sonatypeReleaseUrl = "$sonatypeBaseUrl/service/local/staging/deploy/maven2/" 8 | sonatypeUploadUrl = isSnapshot ? sonatypeSnapshotUrl : sonatypeReleaseUrl 9 | 10 | projectUrl = "https://github.com/Frege/frege-gradle-plugin" 11 | projectName = "Frege Gradle Plugin" 12 | pomProjectName = projectName 13 | baseJarName = "gradle-frege-plugin" 14 | 15 | groupName = "org.frege-lang" 16 | scmUrl = "git://github.com/Frege/frege-gradle-plugin.git" 17 | scmGitFile = "scm:git@github.com:Frege/frege-gradle-plugin.git" 18 | projectDescription = "Frege Gradle plugin" 19 | 20 | licenseName = "BSD 3-clause license" 21 | licenseUrl = 'http://opensource.org/licenses/BSD-3-Clause' 22 | 23 | organisation = groupName 24 | 25 | primaryEmail = "frege-programming-language@googlegroups.com" 26 | } 27 | 28 | Boolean doSigning() { 29 | 30 | signingEnabled.trim() == "true" 31 | } 32 | 33 | task javadocJar(type: Jar, dependsOn: "javadoc") { 34 | classifier = 'javadoc' 35 | from "build/docs/javadoc" 36 | } 37 | 38 | task sourcesJar(type: Jar) { 39 | from sourceSets.main.allSource 40 | classifier = 'sources' 41 | } 42 | 43 | artifacts { 44 | archives jar 45 | archives javadocJar 46 | 47 | archives sourcesJar 48 | } 49 | 50 | signing { 51 | required { doSigning() } 52 | sign configurations.archives 53 | } 54 | 55 | uploadArchives { 56 | enabled = true 57 | repositories { 58 | mavenDeployer { 59 | if (doSigning()) { 60 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 61 | } 62 | 63 | 64 | repository(url: sonatypeUploadUrl) { 65 | authentication(userName: sonatypeUsername, password: sonatypePassword) 66 | } 67 | pom { 68 | groupId = groupName 69 | project { 70 | name pomProjectName 71 | packaging 'jar' 72 | description projectDescription 73 | url projectUrl 74 | organization { 75 | name pomProjectName 76 | url projectUrl 77 | } 78 | scm { 79 | url scmUrl 80 | } 81 | licenses { 82 | license { 83 | name licenseName 84 | url licenseUrl 85 | distribution 'repo' 86 | } 87 | } 88 | developers { 89 | developer { 90 | email primaryEmail 91 | } 92 | } 93 | } 94 | } 95 | } 96 | } 97 | } 98 | 99 | -------------------------------------------------------------------------------- /src/integTest/groovy/frege/gradle/tasks/FregeCompileIntegTest.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | import frege.gradle.integtest.fixtures.AbstractFregeIntegrationSpec 3 | 4 | import static org.gradle.testkit.runner.TaskOutcome.FAILED 5 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 6 | import static org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE 7 | 8 | class FregeCompileIntegTest extends AbstractFregeIntegrationSpec { 9 | 10 | List pluginClasspath 11 | 12 | def setup() { 13 | buildFile << """ 14 | plugins { 15 | id 'org.frege-lang.base' 16 | } 17 | 18 | import frege.gradle.tasks.FregeCompile 19 | 20 | repositories { 21 | jcenter() 22 | flatDir { 23 | dirs '${new File(".").absolutePath}/lib' 24 | } 25 | } 26 | 27 | configurations { frege {} } 28 | 29 | dependencies { 30 | frege "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 31 | } 32 | 33 | task compile(type: FregeCompile) { 34 | destinationDir = file("frege-output") 35 | source("frege-src") 36 | module = "frege-src" 37 | classpath = configurations.frege 38 | fregepath = configurations.frege 39 | } 40 | """ 41 | 42 | testProjectDir.newFolder("frege-src") 43 | } 44 | 45 | def "shows compile errors"() { 46 | given: 47 | simpleFrege() 48 | failingFrege() 49 | when: 50 | def result = fail("compile") 51 | 52 | then: 53 | result.task(":compile").outcome == FAILED 54 | result.output.contains("Failing.fr:6: can't resolve `Hello`") 55 | } 56 | 57 | def "is incremental"() { 58 | given: 59 | simpleFrege() 60 | 61 | buildFile << """ 62 | compile.doLast { 63 | println System.identityHashCode(compile.allJvmArgs) 64 | println compile.allJvmArgs 65 | println compile.allJvmArgs.getClass() 66 | } 67 | """ 68 | when: 69 | def result = run("compile") 70 | 71 | then: 72 | result.task(":compile").outcome == SUCCESS 73 | 74 | when: 75 | result = run("compile") 76 | 77 | then: 78 | result.task(":compile").outcome == UP_TO_DATE 79 | } 80 | 81 | 82 | def failingFrege() { 83 | def failingFrege = testProjectDir.newFile("frege-src/Failing.fr") 84 | failingFrege << """ 85 | 86 | module Failing where 87 | 88 | failingFun _ = do 89 | println(Hello) 90 | """ 91 | } 92 | 93 | def simpleFrege() { 94 | 95 | def helloFrege = testProjectDir.newFile("frege-src/Hello.fr") 96 | helloFrege << """ 97 | 98 | module Hello where 99 | 100 | import frege.prelude.PreludeBase 101 | 102 | main _ = do 103 | println("Hello From Frege") 104 | """ 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/tasks/FregeDoc.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | 3 | import org.gradle.api.Action 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.GradleException 6 | import org.gradle.api.file.FileCollection 7 | import org.gradle.api.tasks.Input 8 | import org.gradle.api.tasks.Optional 9 | import org.gradle.api.tasks.OutputDirectory 10 | import org.gradle.api.tasks.TaskAction 11 | import org.gradle.internal.impldep.org.apache.commons.io.output.TeeOutputStream 12 | import org.gradle.process.JavaExecSpec 13 | 14 | class FregeDoc extends DefaultTask { 15 | 16 | /* Usage: java -jar fregec.jar frege.tools.Doc [-v] [-d opt] [-x mod,...] modules ... 17 | * -v print a message for each processed module 18 | * -d docdir specify root directory for documentation 19 | * Documentation for module x.y.Z will be writen to 20 | * $docdir/x/y/Z.html 21 | * -cp classpath class path for doc tool 22 | * -x mod1[,mod2] exclude modules whose name starts with 'mod1' or 'mod2' 23 | * 24 | * Modules can be specified in three ways: 25 | * my.nice.Modul by name, the Java class for this module must be on the class path 26 | * directory/ all modules that could be loaded if the given directory was on the class path, except exxcluded ones 27 | * path.jar all modules in the specified JAR file, except excluded ones 28 | * 29 | * Example: document base frege distribution without compiler modules 30 | * java -cp fregec.jar frege.tools.Doc -d doc -x frege.compiler fregec.jar 31 | * 32 | */ 33 | 34 | static String DEFAULT_DOCS_SUBDIR = "docs/frege" // TODO: should this come from a convention? 35 | 36 | @Optional 37 | @OutputDirectory 38 | File targetDir = new File(project.buildDir, DEFAULT_DOCS_SUBDIR) 39 | 40 | @Input 41 | String module // module name or directory or class path. Default is all production modules 42 | 43 | @Input 44 | @Optional 45 | String exclude = null 46 | 47 | @Input 48 | @Optional 49 | Boolean verbose = null 50 | 51 | FileCollection classpath 52 | 53 | @TaskAction 54 | void fregedoc() { 55 | ByteArrayOutputStream berr = new ByteArrayOutputStream() 56 | def teeOutputStream = new TeeOutputStream(System.err, berr) 57 | def result = project.javaexec(new Action() { 58 | @Override 59 | void execute(JavaExecSpec javaExecSpec) { 60 | if (verbose) { 61 | javaExecSpec.args '-v' 62 | } 63 | javaExecSpec.args '-d', targetDir.absolutePath 64 | if (exclude) { 65 | javaExecSpec.args '-x', exclude 66 | } 67 | javaExecSpec.args(module) 68 | javaExecSpec.main = "frege.tools.Doc" 69 | javaExecSpec.workingDir = project.projectDir 70 | javaExecSpec.standardInput = System.in 71 | javaExecSpec.standardOutput = System.out 72 | javaExecSpec.errorOutput = teeOutputStream 73 | javaExecSpec.classpath = this.classpath 74 | 75 | javaExecSpec.ignoreExitValue = true 76 | } 77 | }) 78 | 79 | //Workaround for failing with java sources. should result in exit value 0 anyway. 80 | def berrString = berr.toString() 81 | if (result.exitValue !=0 && !berrString.contains("there were errors for")) { 82 | throw new GradleException("Non zero exit value running FregeDoc."); 83 | } 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | import org.gradle.api.DefaultTask 3 | import org.gradle.api.internal.file.FileResolver 4 | import org.gradle.api.tasks.TaskAction 5 | import org.gradle.process.internal.DefaultExecActionFactory 6 | import org.gradle.process.internal.DefaultJavaExecAction 7 | import org.gradle.process.internal.JavaExecAction 8 | 9 | class FregeQuickCheck extends DefaultTask { 10 | 11 | // more options to consider: 12 | /* 13 | Looks up quick check predicates in the given modules and tests them. 14 | 15 | [Usage:] java -cp fregec.jar frege.tools.Quick [ option ... ] modulespec ... 16 | 17 | Options: 18 | 19 | - -v print a line for each pedicate that passed 20 | - -n num run _num_ tests per predicate, default is 100 21 | - -p pred1,pred2,... only test the given predicates 22 | - -x pred1,pred2,... do not test the given predicates 23 | - -l just print the names of the predicates available. 24 | 25 | Ways to specify modules: 26 | 27 | - module the module name (e.g. my.great.Module), will be lookup up in 28 | the current class path. 29 | - dir/ A directory path. The directory is searched for class files, 30 | and for each class files an attempt is made to load it as if 31 | the given directory was in the class path. The directory must 32 | be the root of the classes contained therein, otherwise the 33 | classes won't get loaded. 34 | - path-to.jar A jar or zip file is searched for class files, and for each 35 | class file found an attempt is made to load it as if the 36 | jar was in the class path. 37 | 38 | The number of passed/failed tests is reported. If any test failed or other 39 | errors occured, the exit code will be non zero. 40 | 41 | The code will try to heat up your CPU by running tests on all available cores. 42 | This should be faster on multi-core computers than running the tests 43 | sequentially. It makes it feasable to run more tests per predicate. 44 | 45 | */ 46 | 47 | Boolean verbose = true 48 | Boolean listAvailable = false 49 | Boolean help = false 50 | Integer num = 100 51 | List includePredicates 52 | List excludePredicates 53 | String moduleName 54 | String moduleDirectory 55 | String moduleJar 56 | List classpathDirectories = ["$project.buildDir/classes/main", "$project.buildDir/classes/test"] 57 | String moduleDir = "$project.buildDir/classes/test" 58 | List allJvmArgs = [] 59 | 60 | @TaskAction 61 | void runQuickCheck() { 62 | 63 | FileResolver fileResolver = getServices().get(FileResolver.class) 64 | JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() 65 | action.setMain("frege.tools.Quick") 66 | 67 | action.standardInput = System.in 68 | action.standardOutput = System.out 69 | action.errorOutput = System.err 70 | 71 | def f = project.files(classpathDirectories.collect { s -> new File(s) }) 72 | action.setClasspath(project.files(project.configurations.compile).plus(project.files(project.configurations.testRuntime)).plus(f)) 73 | 74 | 75 | project.configurations.testRuntime.each { println it } 76 | 77 | def args = [] 78 | if (help) { 79 | 80 | } else { 81 | if (verbose) args << "-v" 82 | if (listAvailable) args << "-l" 83 | if (!allJvmArgs.isEmpty()) { 84 | action.setJvmArgs(allJvmArgs) 85 | } 86 | args = args + [moduleDir] 87 | } 88 | logger.info("Calling Frege QuickCheck with args: '$args'") 89 | action.args args 90 | action.execute() 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins; 2 | 3 | import frege.gradle.DefaultFregeSourceSet; 4 | import frege.gradle.FregeSourceSetDirectoryFactory; 5 | import frege.gradle.tasks.FregeCompile; 6 | import org.gradle.api.Action; 7 | import org.gradle.api.Plugin; 8 | import org.gradle.api.Project; 9 | import org.gradle.api.file.FileTreeElement; 10 | import org.gradle.api.internal.file.FileResolver; 11 | import org.gradle.api.internal.plugins.DslObject; 12 | import org.gradle.api.internal.project.ProjectInternal; 13 | import org.gradle.api.internal.tasks.DefaultSourceSet; 14 | import org.gradle.api.plugins.JavaBasePlugin; 15 | import org.gradle.api.plugins.JavaPluginConvention; 16 | import org.gradle.api.specs.Spec; 17 | import org.gradle.api.tasks.SourceSet; 18 | import org.gradle.internal.classpath.DefaultClassPath; 19 | 20 | import javax.inject.Inject; 21 | import java.io.File; 22 | import java.util.concurrent.Callable; 23 | 24 | public class FregeBasePlugin implements Plugin { 25 | private FileResolver fileResolver; 26 | 27 | private static String EXTENSION_NAME = "frege"; 28 | private FregePluginExtension fregePluginExtension; 29 | private Project project; 30 | 31 | @Inject 32 | public FregeBasePlugin(FileResolver fileResolver) { 33 | this.fileResolver = fileResolver; 34 | } 35 | 36 | @Override 37 | public void apply(final Project project) { 38 | // Workaround to build proper jars on Windows, see https://github.com/Frege/frege-gradle-plugin/issues/9 39 | this.project = project; 40 | System.setProperty("file.encoding", "UTF-8"); 41 | project.getPluginManager().apply(JavaBasePlugin.class); 42 | fregePluginExtension = project.getExtensions().create(EXTENSION_NAME, FregePluginExtension.class); 43 | JavaBasePlugin javaBasePlugin = project.getPlugins().getPlugin(JavaBasePlugin.class); 44 | configureSourceSetDefaults(javaBasePlugin); 45 | } 46 | 47 | 48 | private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { 49 | project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action() { 50 | public void execute(final SourceSet sourceSet) { 51 | FregeSourceSetDirectoryFactory factory = new FregeSourceSetDirectoryFactory((ProjectInternal) project, fileResolver); 52 | final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), factory); 53 | new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet); 54 | 55 | final String defaultSourcePath = String.format("src/%s/frege", sourceSet.getName()); 56 | fregeSourceSet.getFrege().srcDir(defaultSourcePath); 57 | sourceSet.getResources().getFilter().exclude(new Spec() { 58 | public boolean isSatisfiedBy(FileTreeElement element) { 59 | return fregeSourceSet.getFrege().contains(element.getFile()); 60 | } 61 | }); 62 | sourceSet.getAllJava().source(fregeSourceSet.getFrege()); 63 | sourceSet.getAllSource().source(fregeSourceSet.getFrege()); 64 | 65 | String compileTaskName = sourceSet.getCompileTaskName("frege"); 66 | FregeCompile compile = project.getTasks().create(compileTaskName, FregeCompile.class); 67 | compile.setModule(project.file(defaultSourcePath).getAbsolutePath()); 68 | // javaBasePlugin.configureForSourceSet(sourceSet, compile); 69 | compile.getConventionMapping().map("fregepath", new Callable() { 70 | public Object call() throws Exception { 71 | return sourceSet.getCompileClasspath(); 72 | } 73 | }); 74 | compile.dependsOn(sourceSet.getCompileJavaTaskName()); 75 | compile.setDescription(String.format("Compiles the %s Frege source.", sourceSet.getName())); 76 | compile.setSource(fregeSourceSet.getFrege()); 77 | 78 | // compile.setClasspath(sourceSet.getCompileClasspath()); 79 | // compile.setDestinationDir((File)null); 80 | 81 | 82 | project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); 83 | sourceSet.compiledBy(compile); 84 | } 85 | }); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.plugins 2 | import frege.gradle.integtest.fixtures.AbstractFregeIntegrationSpec 3 | import org.gradle.testkit.runner.BuildResult 4 | import spock.lang.Unroll 5 | 6 | import static org.gradle.testkit.runner.TaskOutcome.NO_SOURCE 7 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 8 | import static org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE 9 | 10 | class FregePluginIntegTest extends AbstractFregeIntegrationSpec { 11 | 12 | def setup() { 13 | buildFile << """ 14 | plugins { 15 | id 'org.frege-lang' 16 | } 17 | 18 | repositories { 19 | jcenter() 20 | flatDir { 21 | dirs '${new File(".").absolutePath}/lib' 22 | } 23 | } 24 | compileFrege { 25 | classpath = files() 26 | } 27 | """ 28 | } 29 | 30 | def "can handle non existing source directories"() { 31 | given: 32 | buildFile << """ 33 | dependencies { 34 | compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 35 | } 36 | """ 37 | 38 | when: 39 | def result = run(gradleVersion, "classes") 40 | then: 41 | result.task(":compileFrege").outcome == NO_SOURCE 42 | where: 43 | gradleVersion << ["4.0", "5.0", "5.3.1"] 44 | } 45 | 46 | @Unroll 47 | def "can compile and run frege code (gradle: #gradleVersion, frege: #fregeVersion)"() { 48 | given: 49 | buildFile << """ 50 | dependencies { 51 | compile "org.frege-lang:frege:$fregeVersion" 52 | } 53 | ${sayHelloTask()} 54 | """ 55 | 56 | fregeModule() 57 | 58 | when: 59 | def result = run(gradleVersion, "sayHello") 60 | 61 | then: 62 | result.output.contains("Hello Frege!") 63 | result.task(":sayHello").outcome == SUCCESS 64 | 65 | where: 66 | fregeVersion | gradleVersion 67 | DEFAULT_FREGE_VERSION | "5.3.1" 68 | DEFAULT_FREGE_VERSION | "5.0" 69 | DEFAULT_FREGE_VERSION | "4.0" 70 | "3.22.367-g2737683" | "2.12" 71 | } 72 | 73 | private void fregeModule(String modulePath = "src/main/frege/org/frege/HelloFrege.fr") { 74 | def moduleFolder = new File(testProjectDir.root, modulePath).parentFile 75 | moduleFolder.mkdirs() 76 | def moduleSource = testProjectDir.newFile(modulePath) 77 | moduleSource << """ 78 | module org.frege.HelloFrege where 79 | 80 | greeting = "Hello Frege!" 81 | 82 | main _ = do 83 | println greeting 84 | """ 85 | } 86 | 87 | def "can reference java from frege"() { 88 | given: 89 | buildFile << """ 90 | dependencies { 91 | compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 92 | } 93 | ${sayHelloTask()} 94 | """ 95 | 96 | and: 97 | javaCode() 98 | fregeCallingJava() 99 | when: 100 | BuildResult result = run("sayHello") 101 | then: 102 | result.task(":compileJava").outcome == SUCCESS 103 | result.task(":compileFrege").outcome == SUCCESS 104 | result.output.contains("hello from java") 105 | } 106 | 107 | def "can run frege doc on frege module"() { 108 | given: 109 | buildFile << """ 110 | dependencies { 111 | compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 112 | } 113 | ext.destinationDir = "docs" 114 | """ 115 | 116 | and: 117 | fregeModule() 118 | when: 119 | BuildResult result = run("fregeDoc") 120 | then: 121 | result.task(":fregeDoc").outcome == SUCCESS 122 | } 123 | 124 | 125 | def "frege doc works with mixed sources"() { 126 | given: 127 | buildFile << """ 128 | dependencies { 129 | compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 130 | } 131 | """ 132 | 133 | and: 134 | javaCode() 135 | fregeCallingJava() 136 | when: 137 | BuildResult result = run("fregeDoc") 138 | then: 139 | result.task(":fregeDoc").outcome == SUCCESS 140 | } 141 | 142 | def "supports additional source sets"() { 143 | given: 144 | buildFile << """ 145 | 146 | sourceSets { 147 | api 148 | } 149 | 150 | dependencies { 151 | apiCompile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" 152 | } 153 | 154 | 155 | """ 156 | and: 157 | javaCode() 158 | fregeModule("src/api/frege/org/frege/HelloFrege.fr") 159 | when: 160 | BuildResult result = run("apiClasses") 161 | then: 162 | result.task(":compileApiJava").outcome == UP_TO_DATE 163 | result.task(":compileApiFrege").outcome == SUCCESS 164 | classFileExists("api/org/frege/HelloFrege.class") 165 | } 166 | 167 | def classFileExists(String relativeClasspath) { 168 | assert new File(testProjectDir.root, "build/classes/$relativeClasspath/").exists() 169 | true 170 | } 171 | 172 | def fregeCallingJava() { 173 | 174 | File fregeSourceFile = testProjectDir.newFile("src/main/frege/org/frege/HelloFrege.fr") 175 | fregeSourceFile << """ 176 | module org.frege.HelloFrege where 177 | 178 | data StaticHello = pure native org.frege.java.StaticHello where 179 | pure native helloJava org.frege.java.StaticHello.helloJava:: () -> String 180 | 181 | 182 | main _ = do 183 | println(StaticHello.helloJava()) 184 | 185 | """ 186 | } 187 | 188 | def javaCode(String sourceRoot = "java") { 189 | def javaSourceFile = testProjectDir.newFile("src/main/$sourceRoot/org/frege/java/StaticHello.java") 190 | 191 | javaSourceFile << """ 192 | package org.frege.java; 193 | 194 | public class StaticHello { 195 | public static String helloJava() { 196 | return "hello from java"; 197 | } 198 | } 199 | """ 200 | } 201 | 202 | def sayHelloTask() { 203 | return """ task sayHello(type: JavaExec) { 204 | classpath = sourceSets.main.runtimeClasspath 205 | main = 'org.frege.HelloFrege' 206 | } """ 207 | } 208 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /src/main/groovy/frege/gradle/tasks/FregeCompile.groovy: -------------------------------------------------------------------------------- 1 | package frege.gradle.tasks 2 | 3 | import groovy.transform.TypeChecked 4 | import org.gradle.api.Action 5 | import org.gradle.api.file.Directory 6 | import org.gradle.api.file.FileCollection 7 | import org.gradle.api.tasks.Input 8 | import org.gradle.api.tasks.InputFiles 9 | import org.gradle.api.tasks.Optional 10 | import org.gradle.api.tasks.TaskAction 11 | import org.gradle.api.tasks.compile.AbstractCompile 12 | import org.gradle.process.JavaExecSpec 13 | 14 | /* Compiler flags as of 3.25.84 15 | 16 | -d directory target directory for *.java and *.class files 17 | -fp classpath where to find imported frege packages 18 | -enc charset charset for source code files, standard is UTF-8 19 | -enc DEFAULT platform default charset for source code files 20 | -target n.m generate code for java version n.m, also passed to javac 21 | -nocp exclude java classpath from -fp 22 | -hints print more detailed error messages and warnings 23 | -inline inline functions where possible 24 | -strict-pats check patterns in multi-argument functions strictly from left to right 25 | -comments generate commented code 26 | -explain i[-j] print some debugging output from type checker 27 | regarding line(s) i (to j). May help to understand 28 | inexplicable type errors better. 29 | -nowarn don't print warnings (not recommended) 30 | -v verbose mode on 31 | -make build outdated or missing imports 32 | -sp srcpath look for source files in srcpath, default is . 33 | -target x.y generate code for java version x.y, default is the 34 | version of the JVM the compiler is running in. 35 | -j do not run the java compiler 36 | -ascii do not use →, ⇒, ∀ and ∷ when presenting types, 37 | and use ascii characters for java generics variables 38 | -greek make greek type variables 39 | -fraktur make 𝖋𝖗𝖆𝖐𝖙𝖚𝖗 type variables 40 | -latin make latin type variables 41 | 42 | */ 43 | 44 | 45 | 46 | @TypeChecked 47 | class FregeCompile extends AbstractCompile { 48 | 49 | FileCollection classpath 50 | 51 | @Input 52 | String stackSize = "4m" 53 | 54 | @Input 55 | boolean hints = false 56 | 57 | @Input 58 | boolean optimize = false 59 | 60 | @Input 61 | boolean strictPats = false 62 | 63 | @Input 64 | boolean excludeJavaClasspath = false 65 | 66 | boolean verbose = false 67 | 68 | @Input 69 | boolean inline = true 70 | 71 | @Input 72 | boolean make = true 73 | 74 | @Input 75 | boolean compileGeneratedJava = true 76 | 77 | @Input 78 | String target = "" 79 | 80 | @Input 81 | boolean comments = false 82 | 83 | @Input 84 | boolean suppressWarnings = false 85 | 86 | @Input 87 | String explain = "" 88 | 89 | @Input 90 | String extraArgs = "" 91 | 92 | @Input 93 | String allArgs = "" // this is an option to overrule all other settings 94 | 95 | @Input 96 | String module = "" 97 | 98 | @Optional @InputFiles 99 | FileCollection fregepath 100 | 101 | @Input 102 | File destinationDir 103 | 104 | @Input 105 | String mainClass = "frege.compiler.Main" 106 | 107 | @Input 108 | List allJvmArgs = [] 109 | 110 | @Input 111 | String encoding = "" 112 | 113 | @Input 114 | String prefix = "" 115 | 116 | List sourcePaths = [] 117 | 118 | // @Override // spurious compile error 119 | @TaskAction 120 | protected void compile() { 121 | def jvmArgumentsToUse = allJvmArgs.empty ? ["-Xss$stackSize"] : new ArrayList(allJvmArgs) 122 | def compilerArgs = allArgs ? allArgs.split().toList() : assembleArguments() 123 | 124 | logger.info("Calling Frege compiler with compilerArgs: '$compilerArgs'") 125 | //TODO integrate with gradle compiler daemon infrastructure and skip internal execution 126 | project.javaexec(new Action() { 127 | @Override 128 | void execute(JavaExecSpec javaExecSpec) { 129 | javaExecSpec.args = compilerArgs 130 | javaExecSpec.classpath = FregeCompile.this.classpath 131 | javaExecSpec.main = mainClass 132 | javaExecSpec.jvmArgs = jvmArgumentsToUse as List 133 | javaExecSpec.errorOutput = System.err; 134 | javaExecSpec.standardOutput = System.out; 135 | } 136 | }); 137 | 138 | } 139 | 140 | public FregeCompile source(Object... sources) { 141 | super.source(sources); 142 | // track directory roots 143 | for (Object source : sources) { 144 | sourcePaths.add(project.file(source)) 145 | } 146 | return this; 147 | } 148 | 149 | protected List assembleArguments() { 150 | List args = [] 151 | if (hints) 152 | args << "-hints" 153 | if (optimize) { 154 | args << "-O" 155 | args << "-inline" 156 | } 157 | if (inline & !optimize) 158 | args << "-inline" 159 | if (strictPats) 160 | args << "-strict-pats" 161 | if (excludeJavaClasspath) 162 | args << "-nocp" 163 | if (make) 164 | args << "-make" 165 | if (!compileGeneratedJava) 166 | args << "-j" 167 | if (target != "") { 168 | args << "-target" 169 | args << target 170 | } 171 | if (comments) 172 | args << "-comments" 173 | if (suppressWarnings) 174 | args << "-nowarn" 175 | if (explain != "") { 176 | args << "-explain" 177 | args << explain 178 | } 179 | if (verbose) 180 | args << "-v" 181 | 182 | 183 | if (fregepath != null && !fregepath.isEmpty()) { 184 | args << "-fp" 185 | args << fregepath.files.collect { f -> f.absolutePath }.join(File.pathSeparator) 186 | } 187 | 188 | if (sourcePaths != null && !sourcePaths.isEmpty()) { 189 | args << "-sp" 190 | args << sourcePaths.collect { d -> d.absolutePath }.join(File.pathSeparator) 191 | } 192 | 193 | if (encoding != "") { 194 | args << "-enc" 195 | args << encoding 196 | } 197 | 198 | if (prefix != "") { 199 | args << "-prefix" 200 | args << prefix 201 | } 202 | 203 | args << "-d" 204 | args << getDestinationDir().absolutePath 205 | 206 | if (!module.isEmpty()) { 207 | logger.info "compiling module '$module'" 208 | args << module 209 | } else { 210 | args = (args + extraArgs.split().toList()).toList() 211 | } 212 | args 213 | } 214 | } 215 | --------------------------------------------------------------------------------