Last active
September 24, 2015 02:24
-
-
Save mperry/1c18edb8573ee7c1cc1b to your computer and use it in GitHub Desktop.
Frege Gradle project setup script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy this file (frege-init.gradle) to an empty directory. | |
// Setup the project by typing 'gradle -b frege-init.gradle fregeInit'. | |
// You can now run 'gradlew build run' to compile, test and run your application. | |
apply plugin : 'groovy' | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'org.codehaus.groovy:groovy-all:2.4.4' | |
} | |
task fregeInitCheck() { | |
def b = new File("build.gradle").exists() | |
if (b) throw new StopExecutionException("Cannot setup Frege project - this has probably already been done because the build.gradle file already exists.") | |
} | |
task makeDirs() << { | |
def types = ["main", "test"] | |
def langs = ["java", "frege"] | |
def dirs = types.collectMany { t -> langs.collect { l -> "src/$t/$l"} } | |
dirs.each { | |
def f = new File(it) | |
println "Creating dir $f" | |
f.mkdirs() | |
} | |
} | |
task wrap(type : Wrapper) { | |
gradleVersion = '2.7' | |
} | |
task fregeInit(dependsOn: ["makeDirs", "wrap", "writeGradle", "writeFregeMain", "writeFregeTest"]) { | |
mustRunAfter "fregeInitCheck" | |
} | |
task writeFregeMain << { | |
def p = new File("src/main/frege/com") | |
p.mkdirs() | |
def f = new File(p, "Library.fr") | |
f.write(""" | |
module com.Library where | |
greeting = "Hello Frege" | |
main _ = do | |
println greeting | |
""") | |
} | |
task writeFregeTest << { | |
def p = new File("src/test/frege/com") | |
p.mkdirs() | |
def f = new File(p, "LibraryTest.fr") | |
f.write(""" | |
module com.LibraryTest where | |
import Test.QuickCheck | |
testNumberEquality = property(1 == 1) | |
testLength = once(length "hi" == 2) | |
""") | |
} | |
task writeGradle << { | |
def file = new File("build.gradle") | |
file.write(""" | |
buildscript { | |
repositories { | |
mavenLocal() | |
maven { | |
url "https://oss.sonatype.org/content/groups/public" | |
} | |
mavenCentral() | |
} | |
dependencies { | |
classpath 'org.frege-lang:frege-gradle-plugin:0.5-SNAPSHOT' | |
} | |
} | |
apply plugin: "java" | |
apply plugin: "org.frege-lang" | |
apply plugin: "application" | |
defaultTasks "build" | |
mainClassName = "com.Library" | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile "org.frege-lang:frege:3.23.288-gaa3af0c" | |
} | |
""") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment