diff options
43 files changed, 35 insertions, 1629 deletions
@@ -1,28 +1,6 @@ - -# ignore IDEA files -*.iml -*.ipr -*.iws -.idea -# ignore eclipse files -.project -.classpath -.settings -.scala_dependencies -.externalToolBuilders -.factorypath -# ignore others -out -src/test/mod-test -classes -.cache -.DS_Store .gradle -.springBeans -bin +.vscode build -*.pyc +.project -# Ignore Gradle GUI config -gradle-app.setting diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 73f0f47..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: java -jdk: -- oraclejdk7 -sudo: false -env: - global: - - secure: WXBVeS+6GtKNpQnmc00bOEVNRMOsADjg6XRd/PeZMa7IpYBE6HyaIOT/LocJ5J9p3lE6vmNM2kreHjUn6pPk6N3jcT9stbeNSbUFAY52WhmyS9Hq/5qGyuw2rAI+nAVL/yG71HWQsdyrYNjJDMq/CduHf67Gqkn64ihWC4yjr6I= - - secure: RxhrCcuwVLvHdzw0eKE9vxA8rRMs+ZJ+uHu8//YsproWV03FYvit7KwjwvAe8QkLJXl4ePI8XuycTc/xONGqUca0kQ5sO+0ZUytbKKDDWxJ2bE/O741z5TS0ZDypcLwk6BfQyHBEHbd8szsNhe/x3a5kwBE43d5zKI0KCSGJLrU= -after_success: -- chmod +x ./deploy.sh; ./deploy.sh -before_script: -- echo "U=$SONATYPE_USERNAME" -- echo "P=$SONATYPE_PASSWORD" diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ba32583..0000000 --- a/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -Copyright (c) 2015, Frege -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -* Neither the name of frege-gradle-plugin nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/README.adoc b/README.adoc deleted file mode 100644 index 18cbd52..0000000 --- a/README.adoc +++ /dev/null @@ -1,70 +0,0 @@ - -= Frege Gradle Plugin - -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. - -This plugin is an alternative to using Gradle's JavaEx task to start the Frege tools. -Those who prefer the latter might want to have a look at (https://github.com/Dierk/HelloFrege) - -== Plugin Application - -The gradle plugin portal page for Frege documents how to apply the Frege plugin (https://plugins.gradle.org/plugin/org.frege-lang). - -For applying the plugin in all Gradle versions use: -``` -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "gradle.plugin.org.frege-lang:frege-gradle-plugin:0.8" - } -} - -apply plugin: "org.frege-lang" -``` - -To apply the plugin using the new incubating, plugin mechanism (since Gradle 2.1), add: -``` -plugins { - id "org.frege-lang" version "0.8" -} -``` - -== Tasks - -This plugin creates the following tasks: - -* fregeRepl -* fregeQuickCheck -* fregeDoc -* fregeNativeGen -* compileFrege -* compileTestFrege - -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: - -* classes -> compileFrege -> compileJava -* testClasses -> compileTestFrege -> compileTestJava -* test -> fregeQuickCheck -> testClasses - -== Task Help - -TODO: Add options and descriptions for each task above. - -== Example - -See: - -* Plugin application: https://plugins.gradle.org/plugin/org.frege-lang -* Plugin usage: https://github.com/mperry/frege-gradle-example - -== Continuous Integration - -The Travis CI build of this repository is at https://travis-ci.org/Frege/frege-gradle-plugin. - -== Snapshots - -Snapshot releases are available from the Sonatype repository at https://oss.sonatype.org/content/groups/public/org/frege-lang. diff --git a/build.gradle b/build.gradle index d3dd514..728043c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,89 +1,18 @@ -apply plugin: "groovy" -apply plugin: "maven-publish" // I don't think we need this at all -apply plugin: "signing" -apply plugin: "idea" - -apply from: 'gradle/integTest.gradle' - -defaultTasks "build" - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -ext { - baseVersion = "0.9" - isSnapshot = true - snapshotAppendix = "-SNAPSHOT" - projectVersion = baseVersion + (isSnapshot ? snapshotAppendix : "") - projectGroup = "org.frege-lang" - - fregeBaseVersion = "3.25.84" - fregeClassifier = "" - fregeVersion = fregeBaseVersion + fregeClassifier - +plugins { + id 'groovy' + id 'java-gradle-plugin' } -// apply from: "gradle/sonatype.gradle" // not sure why that is here - -version = projectVersion -group = projectGroup - repositories { - mavenLocal() mavenCentral() - - flatDir { - dirs 'lib' - } } dependencies { - implementation "$projectGroup:frege:$fregeVersion" - // api "$projectGroup:frege-repl-core:1.2" // this now comes with the frege distro - implementation "$projectGroup:frege-native-gen:1.3" - // api "org.functionaljava:functionaljava:4.4" // try without - - implementation gradleApi() - implementation localGroovy() - testImplementation gradleTestKit() - - testImplementation('org.spockframework:spock-core:1.0-groovy-2.4') { - exclude module: 'groovy-all' - } -} - -// using the publishing plugin - -buildscript { - repositories { - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath "com.gradle.publish:plugin-publish-plugin:0.9.1" - } + testImplementation group: 'org.spockframework', name: 'spock-core', version: '2.0-groovy-3.0' + testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.2") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2") } -// Details on how to publish to the gradle plugin portal -// Go to http://plugins.gradle.org, get yourself a publishing key -// and add it to ~/.gradle/gradle.properties as -// For publishing, run the task publishPlugins. - -apply plugin: "com.gradle.plugin-publish" - -// The configuration example below shows the minimum required properties -// configured to publish your plugin to the plugin portal -pluginBundle { - website = 'https://github.com/Frege/frege-gradle-plugin' - vcsUrl = 'https://github.com/Frege/frege-gradle-plugin' - description = 'Enabling Frege for compilation, testing, documentation, and supporting tools.' - tags = ['frege', 'haskell', 'java'] - - plugins { - fregePlugin { - id = 'org.frege-lang' - displayName = 'Frege plugin' - } - } -} +tasks.withType(Test).configureEach { + useJUnitPlatform() +}
\ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 7c4658b..0000000 --- a/deploy.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -./gradlew uploadArchives -PsonatypeUsername="${SONATYPE_USERNAME}" -PsonatypePassword="${SONATYPE_PASSWORD}" -i -s -RETVAL=$? - -if [ $RETVAL -eq 0 ]; then - echo 'Completed publish!' -else - echo 'Publish failed.' - return 1 -fi diff --git a/docs/img/FileTypes.png b/docs/img/FileTypes.png Binary files differdeleted file mode 100644 index d50073d..0000000 --- a/docs/img/FileTypes.png +++ /dev/null diff --git a/docs/img/Frege_Gradle_Tasks.png b/docs/img/Frege_Gradle_Tasks.png Binary files differdeleted file mode 100644 index 07c5968..0000000 --- a/docs/img/Frege_Gradle_Tasks.png +++ /dev/null diff --git a/docs/img/external_tool_frepl.png b/docs/img/external_tool_frepl.png Binary files differdeleted file mode 100644 index 3873970..0000000 --- a/docs/img/external_tool_frepl.png +++ /dev/null diff --git a/docs/img/external_tool_run.png b/docs/img/external_tool_run.png Binary files differdeleted file mode 100644 index 496f4bc..0000000 --- a/docs/img/external_tool_run.png +++ /dev/null diff --git a/docs/img/external_tool_test.png b/docs/img/external_tool_test.png Binary files differdeleted file mode 100644 index a44f4ac..0000000 --- a/docs/img/external_tool_test.png +++ /dev/null diff --git a/docs/img/watcher_fregeCompile.png b/docs/img/watcher_fregeCompile.png Binary files differdeleted file mode 100644 index b3b10b0..0000000 --- a/docs/img/watcher_fregeCompile.png +++ /dev/null diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 493b0ae..0000000 --- a/gradle.properties +++ /dev/null @@ -1,8 +0,0 @@ -#currently not needed - -signingEnabled = false -sonatypeUsername = incorrectUsername -sonatypePassword = incorrectPassword - -#(all,none,summary) -org.gradle.warning.mode=all diff --git a/gradle/integTest.gradle b/gradle/integTest.gradle deleted file mode 100644 index 2ce286c..0000000 --- a/gradle/integTest.gradle +++ /dev/null @@ -1,48 +0,0 @@ -sourceSets { - integTest { - compileClasspath += main.output + test.output - runtimeClasspath += main.output + test.output - } -} - -configurations { - integTestCompile.extendsFrom testCompile - integTestRuntime.extendsFrom testRuntime -} - -task integTest(type: Test) { - shouldRunAfter 'test' - testClassesDirs = sourceSets.integTest.output.classesDirs - classpath = sourceSets.integTest.runtimeClasspath -} - -check.dependsOn(integTest) - -plugins.withType(org.gradle.plugins.ide.idea.IdeaPlugin) { - idea { - module { - testSourceDirs += sourceSets.integTest.groovy.srcDirs - testSourceDirs += sourceSets.integTest.resources.srcDirs - scopes.TEST.plus.add(configurations.integTestCompile) - scopes.TEST.plus.add(configurations.integTestRuntime) - } - } -} - - -task createClasspathManifest { - def outputDir = file("$buildDir/$name") - - inputs.files sourceSets.main.runtimeClasspath - outputs.dir outputDir - - doLast { - outputDir.mkdirs() - file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n") - } -} - -dependencies { - testRuntimeOnly files(createClasspathManifest) - // integTestRuntime files(createClasspathManifest) // old -} diff --git a/gradle/sonatype.gradle b/gradle/sonatype.gradle deleted file mode 100644 index adae7e6..0000000 --- a/gradle/sonatype.gradle +++ /dev/null @@ -1,98 +0,0 @@ - -ext { - - sonatypeBaseUrl = "https://oss.sonatype.org" - sonatypeSnapshotUrl = "$sonatypeBaseUrl/content/repositories/snapshots/" - sonatypeRepositoryUrl = "$sonatypeBaseUrl/content/groups/public" - sonatypeReleaseUrl = "$sonatypeBaseUrl/service/local/staging/deploy/maven2/" - sonatypeUploadUrl = isSnapshot ? sonatypeSnapshotUrl : sonatypeReleaseUrl - - projectUrl = "https://github.com/Frege/frege-gradle-plugin" - projectName = "Frege Gradle Plugin" - pomProjectName = projectName - baseJarName = "gradle-frege-plugin" - - groupName = "org.frege-lang" - scmUrl = "git://github.com/Frege/frege-gradle-plugin.git" - scmGitFile = "scm:git@github.com:Frege/frege-gradle-plugin.git" - projectDescription = "Frege Gradle plugin" - - licenseName = "BSD 3-clause license" - licenseUrl = 'http://opensource.org/licenses/BSD-3-Clause' - - organisation = groupName - - primaryEmail = "frege-programming-language@googlegroups.com" -} - -Boolean doSigning() { - - signingEnabled.trim() == "true" -} - -task javadocJar(type: Jar, dependsOn: "javadoc") { - classifier = 'javadoc' - from "build/docs/javadoc" -} - -task sourcesJar(type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' -} - -artifacts { - archives jar - archives javadocJar - - archives sourcesJar -} - -signing { - required { doSigning() } - sign configurations.archives -} - -uploadArchives { - enabled = true - repositories { - mavenDeployer { - if (doSigning()) { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - } - - - repository(url: sonatypeUploadUrl) { - authentication(userName: sonatypeUsername, password: sonatypePassword) - } - pom { - groupId = groupName - project { - name pomProjectName - packaging 'jar' - description projectDescription - url projectUrl - organization { - name pomProjectName - url projectUrl - } - scm { - url scmUrl - } - licenses { - license { - name licenseName - url licenseUrl - distribution 'repo' - } - } - developers { - developer { - email primaryEmail - } - } - } - } - } - } -} - diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differindex 62d4c05..e708b1c 100644 --- a/gradle/wrapper/gradle-wrapper.jar +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9995423..f371643 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Jun 23 13:39:19 CEST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists @@ -130,7 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index a9f778a..ac1b06f 100755..100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,21 +64,6 @@ echo location of your Java installation. goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
diff --git a/lib/frege-3.25.84.jar b/lib/frege-3.25.84.jar Binary files differdeleted file mode 100644 index a0090fc..0000000 --- a/lib/frege-3.25.84.jar +++ /dev/null diff --git a/src/integTest/groovy/frege/gradle/integtest/fixtures/AbstractFregeIntegrationSpec.groovy b/src/integTest/groovy/frege/gradle/integtest/fixtures/AbstractFregeIntegrationSpec.groovy deleted file mode 100644 index 71d3ea8..0000000 --- a/src/integTest/groovy/frege/gradle/integtest/fixtures/AbstractFregeIntegrationSpec.groovy +++ /dev/null @@ -1,67 +0,0 @@ -package frege.gradle.integtest.fixtures - -import org.gradle.testkit.runner.GradleRunner -import org.gradle.testkit.runner.BuildResult -import org.junit.Rule -import org.junit.rules.TemporaryFolder -import spock.lang.Specification - -class AbstractFregeIntegrationSpec extends Specification { - public static final String DEFAULT_FREGE_VERSION = "3.24.405" - List<File> pluginClasspath - - @Rule - final TemporaryFolder testProjectDir = new TemporaryFolder() - File buildFile - - def setup() { - buildFile = testProjectDir.newFile('build.gradle') - - testProjectDir.newFolder("src", "main", "java", "org", "frege", "java") - testProjectDir.newFolder("src", "main", "frege", "org", "frege") - - def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt") - if (pluginClasspathResource == null) { - // try again via file reference - pluginClasspathResource = new File("build/createClasspathManifest/plugin-classpath.txt") - if (pluginClasspathResource == null) { - throw new IllegalStateException("Did not find plugin classpath resource, run `integTestClasses` build task.") - } - } - pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) } - } - - - BuildResult run(String task) { - run(null, task); - } - - BuildResult run(String gradleVersion, String task) { - def writer = new StringWriter(); - GradleRunner runner = newRunner(task, writer, gradleVersion) - def result = runner.build() - println writer; - return result; - } - - BuildResult fail(String task) { - def writer = new StringWriter(); - GradleRunner runner = newRunner(task, writer, null) - def result = runner.buildAndFail() - println writer; - return result; - } - - private GradleRunner newRunner(String task, StringWriter writer, String gradleVersion) { - def runner = GradleRunner.create() - .withProjectDir(testProjectDir.root) - .withArguments(task) - .withPluginClasspath(pluginClasspath) - .forwardStdOutput(writer) - if (gradleVersion) { - runner.withGradleVersion(gradleVersion) - } - runner - } - -} diff --git a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy deleted file mode 100644 index 798d333..0000000 --- a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy +++ /dev/null @@ -1,208 +0,0 @@ -package frege.gradle.plugins -import frege.gradle.integtest.fixtures.AbstractFregeIntegrationSpec -import org.gradle.testkit.runner.BuildResult -import spock.lang.Unroll - -import static org.gradle.testkit.runner.TaskOutcome.NO_SOURCE -import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -import static org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE - -class FregePluginIntegTest extends AbstractFregeIntegrationSpec { - - def setup() { - buildFile << """ - plugins { - id 'org.frege-lang' - } - - repositories { - jcenter() - flatDir { - dirs '${new File(".").absolutePath}/lib' - } - } - compileFrege { - classpath = files() - } - """ - } - - def "can handle non existing source directories"() { - given: - buildFile << """ - dependencies { - compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - """ - - when: - def result = run(gradleVersion, "classes") - then: - result.task(":compileFrege").outcome == NO_SOURCE - where: - gradleVersion << ["4.0", "5.0", "5.3.1"] - } - - @Unroll - def "can compile and run frege code (gradle: #gradleVersion, frege: #fregeVersion)"() { - given: - buildFile << """ - dependencies { - compile "org.frege-lang:frege:$fregeVersion" - } - ${sayHelloTask()} - """ - - fregeModule() - - when: - def result = run(gradleVersion, "sayHello") - - then: - result.output.contains("Hello Frege!") - result.task(":sayHello").outcome == SUCCESS - - where: - fregeVersion | gradleVersion - DEFAULT_FREGE_VERSION | "5.3.1" - DEFAULT_FREGE_VERSION | "5.0" - DEFAULT_FREGE_VERSION | "4.0" - "3.22.367-g2737683" | "2.12" - } - - private void fregeModule(String modulePath = "src/main/frege/org/frege/HelloFrege.fr") { - def moduleFolder = new File(testProjectDir.root, modulePath).parentFile - moduleFolder.mkdirs() - def moduleSource = testProjectDir.newFile(modulePath) - moduleSource << """ - module org.frege.HelloFrege where - - greeting = "Hello Frege!" - - main _ = do - println greeting - """ - } - - def "can reference java from frege"() { - given: - buildFile << """ - dependencies { - compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - ${sayHelloTask()} - """ - - and: - javaCode() - fregeCallingJava() - when: - BuildResult result = run("sayHello") - then: - result.task(":compileJava").outcome == SUCCESS - result.task(":compileFrege").outcome == SUCCESS - result.output.contains("hello from java") - } - - def "can run frege doc on frege module"() { - given: - buildFile << """ - dependencies { - compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - ext.destinationDir = "docs" - """ - - and: - fregeModule() - when: - BuildResult result = run("fregeDoc") - then: - result.task(":fregeDoc").outcome == SUCCESS - } - - - def "frege doc works with mixed sources"() { - given: - buildFile << """ - dependencies { - compile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - """ - - and: - javaCode() - fregeCallingJava() - when: - BuildResult result = run("fregeDoc") - then: - result.task(":fregeDoc").outcome == SUCCESS - } - - def "supports additional source sets"() { - given: - buildFile << """ - - sourceSets { - api - } - - dependencies { - apiCompile "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - - - """ - and: - javaCode() - fregeModule("src/api/frege/org/frege/HelloFrege.fr") - when: - BuildResult result = run("apiClasses") - then: - result.task(":compileApiJava").outcome == UP_TO_DATE - result.task(":compileApiFrege").outcome == SUCCESS - classFileExists("api/org/frege/HelloFrege.class") - } - - def classFileExists(String relativeClasspath) { - assert new File(testProjectDir.root, "build/classes/$relativeClasspath/").exists() - true - } - - def fregeCallingJava() { - - File fregeSourceFile = testProjectDir.newFile("src/main/frege/org/frege/HelloFrege.fr") - fregeSourceFile << """ - module org.frege.HelloFrege where - - data StaticHello = pure native org.frege.java.StaticHello where - pure native helloJava org.frege.java.StaticHello.helloJava:: () -> String - - - main _ = do - println(StaticHello.helloJava()) - - """ - } - - def javaCode(String sourceRoot = "java") { - def javaSourceFile = testProjectDir.newFile("src/main/$sourceRoot/org/frege/java/StaticHello.java") - - javaSourceFile << """ - package org.frege.java; - - public class StaticHello { - public static String helloJava() { - return "hello from java"; - } - } - """ - } - - def sayHelloTask() { - return """ task sayHello(type: JavaExec) { - classpath = sourceSets.main.runtimeClasspath - main = 'org.frege.HelloFrege' - } """ - } -}
\ No newline at end of file diff --git a/src/integTest/groovy/frege/gradle/tasks/FregeCompileIntegTest.groovy b/src/integTest/groovy/frege/gradle/tasks/FregeCompileIntegTest.groovy deleted file mode 100644 index 2f2b9d4..0000000 --- a/src/integTest/groovy/frege/gradle/tasks/FregeCompileIntegTest.groovy +++ /dev/null @@ -1,106 +0,0 @@ -package frege.gradle.tasks -import frege.gradle.integtest.fixtures.AbstractFregeIntegrationSpec - -import static org.gradle.testkit.runner.TaskOutcome.FAILED -import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -import static org.gradle.testkit.runner.TaskOutcome.UP_TO_DATE - -class FregeCompileIntegTest extends AbstractFregeIntegrationSpec { - - List<File> pluginClasspath - - def setup() { - buildFile << """ - plugins { - id 'org.frege-lang.base' - } - - import frege.gradle.tasks.FregeCompile - - repositories { - jcenter() - flatDir { - dirs '${new File(".").absolutePath}/lib' - } - } - - configurations { frege {} } - - dependencies { - frege "org.frege-lang:frege:$DEFAULT_FREGE_VERSION" - } - - task compile(type: FregeCompile) { - destinationDir = file("frege-output") - source("frege-src") - module = "frege-src" - classpath = configurations.frege - fregepath = configurations.frege - } - """ - - testProjectDir.newFolder("frege-src") - } - - def "shows compile errors"() { - given: - simpleFrege() - failingFrege() - when: - def result = fail("compile") - - then: - result.task(":compile").outcome == FAILED - result.output.contains("Failing.fr:6: can't resolve `Hello`") - } - - def "is incremental"() { - given: - simpleFrege() - - buildFile << """ - compile.doLast { - println System.identityHashCode(compile.allJvmArgs) - println compile.allJvmArgs - println compile.allJvmArgs.getClass() - } -""" - when: - def result = run("compile") - - then: - result.task(":compile").outcome == SUCCESS - - when: - result = run("compile") - - then: - result.task(":compile").outcome == UP_TO_DATE - } - - - def failingFrege() { - def failingFrege = testProjectDir.newFile("frege-src/Failing.fr") - failingFrege << """ - - module Failing where - - failingFun _ = do - println(Hello) - """ - } - - def simpleFrege() { - - def helloFrege = testProjectDir.newFile("frege-src/Hello.fr") - helloFrege << """ - - module Hello where - - import frege.prelude.PreludeBase - - main _ = do - println("Hello From Frege") - """ - } -} diff --git a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java b/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java deleted file mode 100644 index a1650a1..0000000 --- a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java +++ /dev/null @@ -1,31 +0,0 @@ -package frege.gradle; - -import groovy.lang.Closure; -import org.gradle.api.file.SourceDirectorySet; -import org.gradle.util.ConfigureUtil; - -public class DefaultFregeSourceSet implements FregeSourceSet { - private final SourceDirectorySet frege; - private final SourceDirectorySet allFrege; - - public DefaultFregeSourceSet(String displayName, FregeSourceSetDirectoryFactory sourceSetFactory) { - this.frege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); - this.frege.getFilter().include(new String[]{"**/*.fr"}); - this.allFrege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); - this.allFrege.source(this.frege); - this.allFrege.getFilter().include(new String[]{"**/*.fr"}); - } - - public SourceDirectorySet getFrege() { - return this.frege; - } - - public FregeSourceSet frege(Closure configureClosure) { - ConfigureUtil.configure(configureClosure, this.getFrege()); - return this; - } - - public SourceDirectorySet getAllFrege() { - return this.allFrege; - } -} diff --git a/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy b/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy deleted file mode 100644 index 35110f5..0000000 --- a/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy +++ /dev/null @@ -1,26 +0,0 @@ -package frege.gradle - -import org.gradle.api.file.FileTree -import org.gradle.api.tasks.util.PatternFilterable - -interface FregeSourceDirectorySet extends PatternFilterable { - def String getName() - - def FregeSourceDirectorySet srcDir(Object srcPath) - - def FregeSourceDirectorySet srcDirs(Object... srcPaths) - - def Set<File> getSrcDirs() - - def FregeSourceDirectorySet setSrcDirs(Iterable<?> srcPaths) - - def FileTree getFiles() - - def PatternFilterable getFilter() - - def FregeSourceSetOutputs getOutput() - - def String getGeneratorTaskName() - - boolean contains(File file) -}
\ No newline at end of file diff --git a/src/main/groovy/frege/gradle/FregeSourceSet.java b/src/main/groovy/frege/gradle/FregeSourceSet.java deleted file mode 100644 index 27654f1..0000000 --- a/src/main/groovy/frege/gradle/FregeSourceSet.java +++ /dev/null @@ -1,8 +0,0 @@ -package frege.gradle; - -import org.gradle.api.file.SourceDirectorySet; - -public interface FregeSourceSet { - SourceDirectorySet getFrege(); - SourceDirectorySet getAllFrege(); -} diff --git a/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy b/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy deleted file mode 100644 index 96abc8f..0000000 --- a/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package frege.gradle - -import org.gradle.api.file.SourceDirectorySet -import org.gradle.api.internal.file.DefaultSourceDirectorySet -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.internal.file.SourceDirectorySetFactory -import org.gradle.api.internal.project.ProjectInternal -import org.gradle.util.GradleVersion - -public class FregeSourceSetDirectoryFactory { - private final boolean useFactory; - private final FileResolver fileResolver - private final ProjectInternal project - - public FregeSourceSetDirectoryFactory(ProjectInternal project, FileResolver fileResolver) { - this.fileResolver = fileResolver - this.project = project - this.useFactory = GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0; - - } - - public SourceDirectorySet newSourceSetDirectory(String displayName) { - if (useFactory) { - SourceDirectorySetFactory factory = project.getServices().get(SourceDirectorySetFactory.class); - return factory.create(displayName); - } else { - return new DefaultSourceDirectorySet(displayName, fileResolver); - } - } -} diff --git a/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy b/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy deleted file mode 100644 index 07e90a3..0000000 --- a/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy +++ /dev/null @@ -1,7 +0,0 @@ -package frege.gradle - -import org.gradle.api.file.FileCollection - -interface FregeSourceSetOutputs { - FileCollection getDirs() -}
\ No newline at end of file diff --git a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java deleted file mode 100644 index 59fe46e..0000000 --- a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java +++ /dev/null @@ -1,87 +0,0 @@ -package frege.gradle.plugins; - -import frege.gradle.DefaultFregeSourceSet; -import frege.gradle.FregeSourceSetDirectoryFactory; -import frege.gradle.tasks.FregeCompile; -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.file.FileTreeElement; -import org.gradle.api.internal.file.FileResolver; -import org.gradle.api.internal.plugins.DslObject; -import org.gradle.api.internal.project.ProjectInternal; -import org.gradle.api.internal.tasks.DefaultSourceSet; -import org.gradle.api.plugins.JavaBasePlugin; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.specs.Spec; -import org.gradle.api.tasks.SourceSet; -import org.gradle.internal.classpath.DefaultClassPath; - -import javax.inject.Inject; -import java.io.File; -import java.util.concurrent.Callable; - -public class FregeBasePlugin implements Plugin<Project> { - private FileResolver fileResolver; - - private static String EXTENSION_NAME = "frege"; - private FregePluginExtension fregePluginExtension; - private Project project; - - @Inject - public FregeBasePlugin(FileResolver fileResolver) { - this.fileResolver = fileResolver; - } - - @Override - 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); - configureSourceSetDefaults(javaBasePlugin); - } - - - private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { - project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { - public void execute(final SourceSet sourceSet) { - FregeSourceSetDirectoryFactory factory = new FregeSourceSetDirectoryFactory((ProjectInternal) project, fileResolver); - final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), factory); - new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet); - - final String defaultSourcePath = String.format("src/%s/frege", sourceSet.getName()); - fregeSourceSet.getFrege().srcDir(defaultSourcePath); - sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() { - public boolean isSatisfiedBy(FileTreeElement element) { - return fregeSourceSet.getFrege().contains(element.getFile()); - } - }); - sourceSet.getAllJava().source(fregeSourceSet.getFrege()); - sourceSet.getAllSource().source(fregeSourceSet.getFrege()); - - String compileTaskName = sourceSet.getCompileTaskName("frege"); - FregeCompile compile = project.getTasks().create(compileTaskName, FregeCompile.class); - compile.setModule(project.file(defaultSourcePath).getAbsolutePath()); -// javaBasePlugin.configureForSourceSet(sourceSet, compile); - compile.getConventionMapping().map("fregepath", new Callable() { - public Object call() throws Exception { - return sourceSet.getCompileClasspath(); - } - }); - compile.dependsOn(sourceSet.getCompileJavaTaskName()); - compile.setDescription(String.format("Compiles the %s Frege source.", sourceSet.getName())); - compile.setSource(fregeSourceSet.getFrege()); - -// compile.setClasspath(sourceSet.getCompileClasspath()); -// compile.setDestinationDir((File)null); - - - project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName); - sourceSet.compiledBy(compile); - } - }); - } -} diff --git a/src/main/groovy/frege/gradle/plugins/FregePlugin.groovy b/src/main/groovy/frege/gradle/plugins/FregePlugin.groovy deleted file mode 100644 index 3dd7ccc..0000000 --- a/src/main/groovy/frege/gradle/plugins/FregePlugin.groovy +++ /dev/null @@ -1,44 +0,0 @@ -package frege.gradle.plugins -import frege.gradle.tasks.FregeDoc -import frege.gradle.tasks.FregeNativeGen -import frege.gradle.tasks.FregeQuickCheck -import frege.gradle.tasks.FregeRepl -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.tasks.SourceSet - -class FregePlugin implements Plugin<Project> { - - Project project - - void apply(Project project) { - this.project = project - - project.plugins.apply(FregeBasePlugin) - project.plugins.apply("java") - - def replTask = project.task('fregeRepl', type: FregeRepl, group: 'frege', dependsOn: 'compileFrege') - replTask.outputs.upToDateWhen { false } // always run, regardless of up to date checks - - def checkTask = project.task('fregeQuickCheck', type: FregeQuickCheck, group: 'frege', dependsOn: 'testClasses') - checkTask.outputs.upToDateWhen { false } // always run, regardless of up to date checks - - project.tasks.test.dependsOn("fregeQuickCheck") - - - configureFregeDoc() - - project.task('fregeNativeGen', type: FregeNativeGen, group: 'frege') - - } - - def configureFregeDoc() { - FregeDoc fregeDoc = project.tasks.create('fregeDoc', FregeDoc) - fregeDoc.group = 'frege' - fregeDoc.dependsOn "compileFrege" // TODO remove - SourceSet mainSourceSet = project.sourceSets.main - fregeDoc.module = mainSourceSet.output.classesDirs.first().absolutePath - fregeDoc.classpath = mainSourceSet.runtimeClasspath - } - -} diff --git a/src/main/groovy/frege/gradle/plugins/FregePluginExtension.groovy b/src/main/groovy/frege/gradle/plugins/FregePluginExtension.groovy deleted file mode 100644 index ae180ec..0000000 --- a/src/main/groovy/frege/gradle/plugins/FregePluginExtension.groovy +++ /dev/null @@ -1,11 +0,0 @@ -package frege.gradle.plugins - -/** - * Created by mperry on 6/02/2015. - */ -class FregePluginExtension { - - - String key1 - -} diff --git a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy b/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy deleted file mode 100644 index d619158..0000000 --- a/src/main/groovy/frege/gradle/tasks/FregeCompile.groovy +++ /dev/null @@ -1,214 +0,0 @@ -package frege.gradle.tasks - -import groovy.transform.TypeChecked -import org.gradle.api.Action -import org.gradle.api.file.Directory -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFiles -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.TaskAction -import org.gradle.api.tasks.compile.AbstractCompile -import org.gradle.process.JavaExecSpec - -/* Compiler flags as of 3.25.84 - --d directory target directory for *.java and *.class files --fp classpath where to find imported frege packages --enc charset charset for source code files, standard is UTF-8 --enc DEFAULT platform default charset for source code files --target n.m generate code for java version n.m, also passed to javac --nocp exclude java classpath from -fp --hints print more detailed error messages and warnings --inline inline functions where possible --strict-pats check patterns in multi-argument functions strictly from left to right --comments generate commented code --explain i[-j] print some debugging output from type checker - regarding line(s) i (to j). May help to understand - inexplicable type errors better. --nowarn don't print warnings (not recommended) --v verbose mode on --make build outdated or missing imports --sp srcpath look for source files in srcpath, default is . --target x.y generate code for java version x.y, default is the - version of the JVM the compiler is running in. --j do not run the java compiler --ascii do not use →, ⇒, ∀ and ∷ when presenting types, - and use ascii characters for java generics variables --greek make greek type variables --fraktur make 𝖋𝖗𝖆𝖐𝖙𝖚𝖗 type variables --latin make latin type variables - -*/ - - - -@TypeChecked -class FregeCompile extends AbstractCompile { - - FileCollection classpath - - @Input - String stackSize = "4m" - - @Input - boolean hints = false - - @Input - boolean optimize = false - - @Input - boolean strictPats = false - - @Input - boolean excludeJavaClasspath = false - - boolean verbose = false - - @Input - boolean inline = true - - @Input - boolean make = true - - @Input - boolean compileGeneratedJava = true - - @Input - String target = "" - - @Input - boolean comments = false - - @Input - boolean suppressWarnings = false - - @Input - String explain = "" - - @Input - String extraArgs = "" - - @Input - String allArgs = "" // this is an option to overrule all other settings - - @Input - String module = "" - - @Optional @InputFiles - FileCollection fregepath - - @Input - File destinationDir - - @Input - String mainClass = "frege.compiler.Main" - - @Input - List<String> allJvmArgs = [] - - @Input - String encoding = "" - - @Input - String prefix = "" - - List<File> sourcePaths = [] - - // @Override // spurious compile error - @TaskAction - protected void compile() { - def jvmArgumentsToUse = allJvmArgs.empty ? ["-Xss$stackSize"] : new ArrayList<String>(allJvmArgs) - def compilerArgs = allArgs ? allArgs.split().toList() : assembleArguments() - - logger.info("Calling Frege compiler with compilerArgs: '$compilerArgs'") - //TODO integrate with gradle compiler daemon infrastructure and skip internal execution - project.javaexec(new Action<JavaExecSpec>() { - @Override - void execute(JavaExecSpec javaExecSpec) { - javaExecSpec.args = compilerArgs - javaExecSpec.classpath = FregeCompile.this.classpath - javaExecSpec.main = mainClass - javaExecSpec.jvmArgs = jvmArgumentsToUse as List<String> - javaExecSpec.errorOutput = System.err; - javaExecSpec.standardOutput = System.out; - } - }); - - } - - public FregeCompile source(Object... sources) { - super.source(sources); - // track directory roots - for (Object source : sources) { - sourcePaths.add(project.file(source)) - } - return this; - } - - protected List<String> assembleArguments() { - List args = [] - if (hints) - args << "-hints" - if (optimize) { - args << "-O" - args << "-inline" - } - if (inline & !optimize) - args << "-inline" - if (strictPats) - args << "-strict-pats" - if (excludeJavaClasspath) - args << "-nocp" - if (make) - args << "-make" - if (!compileGeneratedJava) - args << "-j" - if (target != "") { - args << "-target" - args << target - } - if (comments) - args << "-comments" - if (suppressWarnings) - args << "-nowarn" - if (explain != "") { - args << "-explain" - args << explain - } - if (verbose) - args << "-v" - - - if (fregepath != null && !fregepath.isEmpty()) { - args << "-fp" - args << fregepath.files.collect { f -> f.absolutePath }.join(File.pathSeparator) - } - - if (sourcePaths != null && !sourcePaths.isEmpty()) { - args << "-sp" - args << sourcePaths.collect { d -> d.absolutePath }.join(File.pathSeparator) - } - - if (encoding != "") { - args << "-enc" - args << encoding - } - - if (prefix != "") { - args << "-prefix" - args << prefix - } - - args << "-d" - args << getDestinationDir().absolutePath - - if (!module.isEmpty()) { - logger.info "compiling module '$module'" - args << module - } else { - args = (args + extraArgs.split().toList()).toList() - } - args - } -} diff --git a/src/main/groovy/frege/gradle/tasks/FregeDoc.groovy b/src/main/groovy/frege/gradle/tasks/FregeDoc.groovy deleted file mode 100644 index ddd7bca..0000000 --- a/src/main/groovy/frege/gradle/tasks/FregeDoc.groovy +++ /dev/null @@ -1,86 +0,0 @@ -package frege.gradle.tasks - -import org.gradle.api.Action -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction -import org.gradle.internal.impldep.org.apache.commons.io.output.TeeOutputStream -import org.gradle.process.JavaExecSpec - -class FregeDoc extends DefaultTask { - - /* Usage: java -jar fregec.jar frege.tools.Doc [-v] [-d opt] [-x mod,...] modules ... - * -v print a message for each processed module - * -d docdir specify root directory for documentation - * Documentation for module x.y.Z will be writen to - * $docdir/x/y/Z.html - * -cp classpath class path for doc tool - * -x mod1[,mod2] exclude modules whose name starts with 'mod1' or 'mod2' - * - * Modules can be specified in three ways: - * my.nice.Modul by name, the Java class for this module must be on the class path - * directory/ all modules that could be loaded if the given directory was on the class path, except exxcluded ones - * path.jar all modules in the specified JAR file, except excluded ones - * - * Example: document base frege distribution without compiler modules - * java -cp fregec.jar frege.tools.Doc -d doc -x frege.compiler fregec.jar - * - */ - - static String DEFAULT_DOCS_SUBDIR = "docs/frege" // TODO: should this come from a convention? - - @Optional - @OutputDirectory - File targetDir = new File(project.buildDir, DEFAULT_DOCS_SUBDIR) - - @Input - String module // module name or directory or class path. Default is all production modules - - @Input - @Optional - String exclude = null - - @Input - @Optional - Boolean verbose = null - - FileCollection classpath - - @TaskAction - void fregedoc() { - ByteArrayOutputStream berr = new ByteArrayOutputStream() - def teeOutputStream = new TeeOutputStream(System.err, berr) - def result = project.javaexec(new Action<JavaExecSpec>() { - @Override - void execute(JavaExecSpec javaExecSpec) { - if (verbose) { - javaExecSpec.args '-v' - } - javaExecSpec.args '-d', targetDir.absolutePath - if (exclude) { - javaExecSpec.args '-x', exclude - } - javaExecSpec.args(module) - javaExecSpec.main = "frege.tools.Doc" - javaExecSpec.workingDir = project.projectDir - javaExecSpec.standardInput = System.in - javaExecSpec.standardOutput = System.out - javaExecSpec.errorOutput = teeOutputStream - javaExecSpec.classpath = this.classpath - - javaExecSpec.ignoreExitValue = true - } - }) - - //Workaround for failing with java sources. should result in exit value 0 anyway. - def berrString = berr.toString() - if (result.exitValue !=0 && !berrString.contains("there were errors for")) { - throw new GradleException("Non zero exit value running FregeDoc."); - } - } -} - diff --git a/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy b/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy deleted file mode 100644 index 02edefd..0000000 --- a/src/main/groovy/frege/gradle/tasks/FregeNativeGen.groovy +++ /dev/null @@ -1,61 +0,0 @@ -package frege.gradle.tasks - -import org.gradle.api.DefaultTask -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile -import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction -import org.gradle.process.internal.DefaultExecActionFactory -import org.gradle.process.internal.DefaultJavaExecAction -import org.gradle.process.internal.JavaExecAction - -class FregeNativeGen extends DefaultTask { - - /* - * Example from https://github.com/Frege/frege-native-gen: - * 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 - */ - - // help not currently supported by native gen tool - Boolean help = false - - @Optional - @InputFile - File typesFile = new File(project.projectDir, "types.properties") - - @Input - String className = null - - @Optional - @OutputFile - File outputFile = new File(project.buildDir, "generated/frege/NativeGenOutput.fr") - - - @TaskAction - void gen() { - - FileResolver fileResolver = getServices().get(FileResolver.class) - JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() - action.setMain("frege.nativegen.Main") - action.workingDir = project.projectDir - action.standardInput = System.in - action.standardOutput = outputFile.newOutputStream() - action.errorOutput = System.err - action.setClasspath(project.files(project.configurations.compile) + project.files("$project.buildDir/classes/main")) - - def args = [] - if (help) { - args << "-h" - } else { - args << className - args << typesFile.absolutePath - } - logger.info("Calling Frege NativeGen with args: '$args'") - action.args args - action.execute() - } - - -} diff --git a/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy b/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy deleted file mode 100644 index afeacac..0000000 --- a/src/main/groovy/frege/gradle/tasks/FregeQuickCheck.groovy +++ /dev/null @@ -1,93 +0,0 @@ -package frege.gradle.tasks -import org.gradle.api.DefaultTask -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.tasks.TaskAction -import org.gradle.process.internal.DefaultExecActionFactory -import org.gradle.process.internal.DefaultJavaExecAction -import org.gradle.process.internal.JavaExecAction - -class FregeQuickCheck extends DefaultTask { - - // more options to consider: -/* - Looks up quick check predicates in the given modules and tests them. - - [Usage:] java -cp fregec.jar frege.tools.Quick [ option ... ] modulespec ... - - Options: - - - -v print a line for each pedicate that passed - - -n num run _num_ tests per predicate, default is 100 - - -p pred1,pred2,... only test the given predicates - - -x pred1,pred2,... do not test the given predicates - - -l just print the names of the predicates available. - - Ways to specify modules: - - - module the module name (e.g. my.great.Module), will be lookup up in - the current class path. - - dir/ A directory path. The directory is searched for class files, - and for each class files an attempt is made to load it as if - the given directory was in the class path. The directory must - be the root of the classes contained therein, otherwise the - classes won't get loaded. - - path-to.jar A jar or zip file is searched for class files, and for each - class file found an attempt is made to load it as if the - jar was in the class path. - - The number of passed/failed tests is reported. If any test failed or other - errors occured, the exit code will be non zero. - - The code will try to heat up your CPU by running tests on all available cores. - This should be faster on multi-core computers than running the tests - sequentially. It makes it feasable to run more tests per predicate. - - */ - - Boolean verbose = true - Boolean listAvailable = false - Boolean help = false - Integer num = 100 - List<String> includePredicates - List<String> excludePredicates - String moduleName - String moduleDirectory - String moduleJar - List<String> classpathDirectories = ["$project.buildDir/classes/main", "$project.buildDir/classes/test"] - String moduleDir = "$project.buildDir/classes/test" - List<String> allJvmArgs = [] - - @TaskAction - void runQuickCheck() { - - FileResolver fileResolver = getServices().get(FileResolver.class) - JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() - action.setMain("frege.tools.Quick") - - action.standardInput = System.in - action.standardOutput = System.out - action.errorOutput = System.err - - def f = project.files(classpathDirectories.collect { s -> new File(s) }) - action.setClasspath(project.files(project.configurations.compile).plus(project.files(project.configurations.testRuntime)).plus(f)) - - - project.configurations.testRuntime.each { println it } - - def args = [] - if (help) { - - } else { - if (verbose) args << "-v" - if (listAvailable) args << "-l" - if (!allJvmArgs.isEmpty()) { - action.setJvmArgs(allJvmArgs) - } - args = args + [moduleDir] - } - logger.info("Calling Frege QuickCheck with args: '$args'") - action.args args - action.execute() - } - -} diff --git a/src/main/groovy/frege/gradle/tasks/FregeRepl.groovy b/src/main/groovy/frege/gradle/tasks/FregeRepl.groovy deleted file mode 100644 index 693e076..0000000 --- a/src/main/groovy/frege/gradle/tasks/FregeRepl.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package frege.gradle.tasks - -import org.gradle.api.DefaultTask -import org.gradle.api.internal.file.FileResolver -import org.gradle.api.tasks.* -import org.gradle.process.internal.DefaultExecActionFactory -import org.gradle.process.internal.DefaultJavaExecAction -import org.gradle.process.internal.JavaExecAction - -class FregeRepl extends DefaultTask { - - static String DEFAULT_SRC_DIR = "src/main/frege" // TODO: should this come from a source set? - static String DEFAULT_CLASSES_SUBDIR = "classes/main" // TODO: should this come from a convention? - - @Optional @InputDirectory - File sourceDir = new File(project.projectDir, DEFAULT_SRC_DIR).exists() ? new File(project.projectDir, DEFAULT_SRC_DIR) : null - - @Optional @OutputDirectory - File targetDir = new File(project.buildDir, DEFAULT_CLASSES_SUBDIR) - - @TaskAction - void openFregeRepl() { - - if (sourceDir != null && !sourceDir.exists() ) { - def currentDir = new File('.') - logger.info "Intended source dir '${sourceDir.absolutePath}' doesn't exist. Using current dir '${currentDir.absolutePath}' ." - sourceDir = currentDir - } - - FileResolver fileResolver = getServices().get(FileResolver.class) - JavaExecAction action = new DefaultExecActionFactory(fileResolver).newJavaExecAction() - action.setMain("frege.repl.FregeRepl") - action.workingDir = sourceDir ?: project.projectDir - action.standardInput = System.in - action.setClasspath(project.files(project.configurations.runtime ) + project.files(targetDir.absolutePath)) - - action.execute() - } - -} diff --git a/src/main/resources/META-INF/gradle-plugins/org.frege-lang.base.properties b/src/main/resources/META-INF/gradle-plugins/org.frege-lang.base.properties deleted file mode 100644 index 50f947e..0000000 --- a/src/main/resources/META-INF/gradle-plugins/org.frege-lang.base.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=frege.gradle.plugins.FregeBasePlugin diff --git a/src/main/resources/META-INF/gradle-plugins/org.frege-lang.properties b/src/main/resources/META-INF/gradle-plugins/org.frege-lang.properties deleted file mode 100644 index db20350..0000000 --- a/src/main/resources/META-INF/gradle-plugins/org.frege-lang.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=frege.gradle.plugins.FregePlugin diff --git a/src/test/groovy/ch.fhnw.thga.fregeplugin/FregePluginFunctionalTest.groovy b/src/test/groovy/ch.fhnw.thga.fregeplugin/FregePluginFunctionalTest.groovy new file mode 100644 index 0000000..889f6f0 --- /dev/null +++ b/src/test/groovy/ch.fhnw.thga.fregeplugin/FregePluginFunctionalTest.groovy @@ -0,0 +1,18 @@ +package ch.fhnw.thga.fregeplugin + +import org.junit.jupiter.api.io.TempDir; +import spock.lang.Specification + +class FregePluginFunctionalTests extends Specification { + @TempDir File testProjectDir + File buildFile + + def setup() { + buildFile = newFile(testProjectDir, 'build.gradle') + buildFile << """ + plugins { + id 'ch.fhnw.thga.frege' + } + """ + } +}
\ No newline at end of file diff --git a/src/test/groovy/frege/gradle/plugins/FregeBasePluginTest.groovy b/src/test/groovy/frege/gradle/plugins/FregeBasePluginTest.groovy deleted file mode 100644 index 04b5587..0000000 --- a/src/test/groovy/frege/gradle/plugins/FregeBasePluginTest.groovy +++ /dev/null @@ -1,30 +0,0 @@ -package frege.gradle.plugins - -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder -import spock.lang.Specification - -public class FregeBasePluginTest extends Specification { - - Project project = ProjectBuilder.builder().build() - - def setup(){ - when: - project.plugins.apply(FregeBasePlugin) - } - - def "adds frege extension"(){ - expect: - project.getExtensions().getByName(FregeBasePlugin.EXTENSION_NAME) != null - } - - def "applies java base plugin"(){ - expect: - project.pluginManager.hasPlugin("java-base") - } - - def "can be identified by id"(){ - expect: - project.pluginManager.hasPlugin("org.frege-lang.base") - } -}
\ No newline at end of file diff --git a/src/test/groovy/frege/gradle/plugins/FregePluginTest.groovy b/src/test/groovy/frege/gradle/plugins/FregePluginTest.groovy deleted file mode 100644 index 34532c7..0000000 --- a/src/test/groovy/frege/gradle/plugins/FregePluginTest.groovy +++ /dev/null @@ -1,36 +0,0 @@ -package frege.gradle.plugins -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder -import spock.lang.Specification -import spock.lang.Unroll - -class FregePluginTest extends Specification { - - Project project = ProjectBuilder.builder().build() - - def setup(){ - when: - project.plugins.apply(FregePlugin) - } - - def "applies frege base plugin"() { - expect: - project.pluginManager.findPlugin("org.frege-lang.base") != null - } - - def "can be identified by id"(){ - expect: - project.pluginManager.hasPlugin("org.frege-lang") - } - - @Unroll - def "adds #fregeTaskName task"(){ - when: - def fregeTask = project.tasks.findByName(fregeTaskName) - then: - fregeTask != null - fregeTask.group == "frege" - where: - fregeTaskName << ["fregeRepl", "fregeDoc", "fregeQuickCheck", "fregeNativeGen"] - } -} diff --git a/src/test/groovy/frege/gradle/tasks/FregeCompileTest.groovy b/src/test/groovy/frege/gradle/tasks/FregeCompileTest.groovy deleted file mode 100644 index c9224ea..0000000 --- a/src/test/groovy/frege/gradle/tasks/FregeCompileTest.groovy +++ /dev/null @@ -1,39 +0,0 @@ -package frege.gradle.tasks - -import org.gradle.api.Project -import org.gradle.testfixtures.ProjectBuilder -import spock.lang.Specification - -class FregeCompileTest extends Specification { - Project project = ProjectBuilder.builder().build() - FregeCompile compile - - def setup() { - when: - compile = project.tasks.create("fregeCompile", FregeCompile) - } - - - def "configured sourcePaths tracked"() { - when: - compile.source("someFolder") - then: - compile.sourcePaths == [project.file("someFolder")] - } - - - def "default assembleArguments"() { - given: - compile.destinationDir = project.file("testoutput") - expect: - compile.assembleArguments() == ["-inline", "-make", "-d", project.file("testoutput").absolutePath] - } - - def "with prefix"() { - given: - compile.destinationDir = project.file("testoutput") - compile.prefix = "somePrefix" - expect: - compile.assembleArguments() == ["-inline", "-make", "-prefix", "somePrefix", "-d", project.file("testoutput").absolutePath] - } -} diff --git a/todo.txt b/todo.txt deleted file mode 100644 index c4ac830..0000000 --- a/todo.txt +++ /dev/null @@ -1 +0,0 @@ -- make a compileTestFrege with the respective task dependencies |