Skip to content

Commit

Permalink
Basic Module and Framework infrastructure
Browse files Browse the repository at this point in the history
Note that the EtlasModuleBuilder is currently incomplete
  • Loading branch information
carymrobbins committed Mar 1, 2018
1 parent d73c198 commit 00b1b19
Show file tree
Hide file tree
Showing 457 changed files with 1,933 additions and 103 deletions.
253 changes: 161 additions & 92 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import com.typelead.gradle.utils.EtaRuntimeUtils
import org.gradle.internal.jvm.Jvm

import java.util.function.BiConsumer

// Depend on local gradle-eta plugin.
buildscript {
repositories {
mavenLocal()

dependencies {
classpath 'com.typelead:gradle-eta:0.0.1-SNAPSHOT-785fcdb'
classpath 'com.typelead:gradle-eta:0.0.1-SNAPSHOT-fd00812'
}
}
}
Expand All @@ -15,113 +18,162 @@ plugins {
id "org.jetbrains.intellij" version "0.2.17"
}

group 'com.typelead'
version = file('version.txt').text.trim()

apply plugin: 'java'
apply plugin: 'eta'
apply plugin: 'org.jetbrains.intellij'
group 'com.typelead'

ext {
javaVersion = '1.8'
}

intellij {
version = '2017.3'
pluginName = 'IntelliJ-Eta'
// Makes it easy to support multiple intellij versions.
// If we want to set this to true, we should find a way to cross build
// against multiple intellij versions.
updateSinceUntilBuild = false
instrumentCode = false
task runJFlex(type: Exec) {
commandLine './tools/run-jflex'
}

eta {
useSystemEtlas = true
task cleanJFlex(type: Exec) {
commandLine './tools/run-jflex', 'clean'
}

sourceCompatibility = 1.8
allprojects {

repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'org.jetbrains.intellij'

dependencies {
testCompile fileTree(dir: 'build/etlas/dist/build', include: 'HSintellij-eta-*.jar')
}
repositories {
mavenCentral()
}

configurations {
provided
compile.extendsFrom provided
}

intellij {
version = '2017.3'
pluginName = 'IntelliJ-Eta'
// Makes it easy to support multiple intellij versions.
// If we want to set this to true, we should find a way to cross build
// against multiple intellij versions.
updateSinceUntilBuild = false
}

task hpack(type: Exec) {
commandLine 'hpack'
sourceCompatibility = 1.8
}

sandboxAddSourcesEta {
sources = ['eta-parser']
inputs.property('etlas_add_source', sources)
outputs.files('.cabal-sandbox/add-source-timestamps')
task cleanEtaParserSources(type: Exec) {
workingDir file('eta-parser')
commandLine = ['make', 'clean']
}

clean.dependsOn(cleanEtaParserSources)

task makeEtaParserSources(type: Exec) {
workingDir file('eta-parser')
commandLine = ['make', 'sources']
commandLine = ['make', 'hpack', 'sources']
['eta', 'java', 'patches', 'tools'].each { inputs.dir(it) }
['eta-parser.cabal', 'Makefile'].each { inputs.file(it) }
}

installDepsEta.dependsOn(hpack, makeEtaParserSources)
project(':plugin') {

[installDepsEta,installTestDepsEta].forEach {
it.inputs.files('package.yaml')
it.outputs.dir('.cabal-sandbox/lib')
}
apply plugin: 'eta'

task runJFlex(type: Exec) {
commandLine './tools/run-jflex'
}
eta {
useSystemEtlas = true
}

task cleanJFlex(type: Exec) {
commandLine './tools/run-jflex', 'clean'
}
task hpack(type: Exec) {
commandLine 'hpack'
}

compileJava.dependsOn(runJFlex)
cleanEta.dependsOn(hpack)

clean.dependsOn(cleanJFlex)
sandboxAddSourcesEta {
sources = ['../eta-parser']
inputs.property('etlas_add_source', sources)
outputs.files('.cabal-sandbox/add-source-timestamps')
}

compileEta {
inputs.dir('src/main/eta')
outputs.files('build/etlas/dist/build/HSintellij-eta*.jar')
}
installDepsEta.dependsOn(hpack, makeEtaParserSources)

compileTestJava.dependsOn(compileEta)
[installDepsEta, installTestDepsEta].forEach {
it.inputs.files('package.yaml')
it.outputs.dir('.cabal-sandbox/lib')
}

testCompileEta {
inputs.files('src/test/eta')
outputs.files('build/etlas/dist/build/test/test.jar')
}
dependencies {
compile project(':jps-shared')
compile project(':jps-plugin')
testCompile fileTree(dir: "${project.buildDir}/etlas/dist/build", include: 'HSintellij-eta-*.jar')
}

testCompileEta.dependsOn(compileTestJava)
compileJava.dependsOn(runJFlex)

prepareSandbox {
doLast {
copyEtaRuntimeToPluginSandbox(false)
clean.dependsOn(cleanJFlex)

compileTestJava.dependsOn(compileEta)

testCompileEta {
inputs.files('src/test/eta')
outputs.files("${project.buildDir}/etlas/dist/build/test/test.jar")
}
}

prepareSandbox.dependsOn(compileEta)
testCompileEta.dependsOn(compileTestJava)

prepareTestingSandbox {
doLast {
copyEtaRuntimeToPluginSandbox(true)
prepareSandbox {
doLast {
copyEtaRuntimeToPluginSandbox(project, false)
}
}

prepareSandbox.dependsOn(compileEta)

prepareTestingSandbox {
doLast {
copyEtaRuntimeToPluginSandbox(project, true)
}
}

prepareTestingSandbox.dependsOn(testCompileEta)

// Hack to trick junit into thinking we have java tests.
testClasses {
dependsOn testCompileEta
doLast {
copy {
from zipTree("${project.buildDir}/etlas/dist/build/test/test.jar")
into "${project.buildDir}/classes/test"
}
}
}

testClasses.dependsOn(testCompileEta)

task configureTest {
dependsOn testCompileEta
doLast {
test.classpath += files(getEtaRuntimeClasspath(project))
}
}

test {
dependsOn configureTest
}
}

prepareTestingSandbox.dependsOn(testCompileEta)
project(':jps-plugin') {
dependencies {
compile project(':jps-shared')
}
}

def getSandboxLibDir(Boolean test) {
static def getSandboxLibDir(Project project, Boolean test) {
def pluginsDir = test ? "plugins-test" : "plugins"
"${intellij.sandboxDirectory}/$pluginsDir/${intellij.pluginName}/lib/"
"${project.intellij.sandboxDirectory}/$pluginsDir/${project.intellij.pluginName}/lib/"
}

Set<File> getEtaRuntimeClasspath() {
if (eta.etlasBinary == null) {
static Set<File> getEtaRuntimeClasspath(Project project) {
if (project.eta.etlasBinary == null) {
throw new GradleException(
"Cannot getEtaRuntimeClasspath, eta.etlasBinary is null; "
+ "consider running in a doLast { .. } block instead."
Expand All @@ -131,17 +183,17 @@ Set<File> getEtaRuntimeClasspath() {
// Attempt at caching the runtime, later we can build this into gradle-eta (using ~/.gradle/caches)
def useCache = true
if (useCache) {
File cachedRuntimeFile = new File("build/etlas/runtime/$component")
File cachedRuntimeFile = new File(project.buildDir, "etlas/runtime/$component")
if (!cachedRuntimeFile.exists()
|| cachedRuntimeFile.lastModified() < new File('package.yaml').lastModified()) {
|| cachedRuntimeFile.lastModified() < new File(project.projectDir, 'package.yaml').lastModified()) {
if (cachedRuntimeFile.exists()) {
cachedRuntimeFile.write('')
} else {
cachedRuntimeFile.getParentFile().mkdirs()
}
logger.info("Requesting eta runtime classpath...")
def res = EtaRuntimeUtils.getRuntimeClasspath(project, eta, component)
logger.info("Using eta runtime classpath: $res")
project.logger.info("Requesting eta runtime classpath...")
def res = EtaRuntimeUtils.getRuntimeClasspath(project, project.eta, component)
project.logger.info("Using eta runtime classpath: $res")
res.each { cachedRuntimeFile.append(it.path + '\n') }
res
} else {
Expand All @@ -150,46 +202,63 @@ Set<File> getEtaRuntimeClasspath() {
cachedRuntimeFile.eachLine {
if (!it.isEmpty()) res.add(new File(it))
}
logger.info("Using cached eta runtime classpath: $res")
project.logger.info("Using cached eta runtime classpath: $res")
res
}
} else {
def res = EtaRuntimeUtils.getRuntimeClasspath(project, eta, component)
logger.info("Using eta runtime classpath: $res")
def res = EtaRuntimeUtils.getRuntimeClasspath(project, project.eta, component)
project.logger.info("Using eta runtime classpath: $res")
res
}
}

def copyEtaRuntimeToPluginSandbox(Boolean test) {
def dest = getSandboxLibDir(test)
getEtaRuntimeClasspath().forEach { dep ->
def copyEtaRuntimeToPluginSandbox(Project project, Boolean test) {
def dest = getSandboxLibDir(project, test)
getEtaRuntimeClasspath(project).forEach { dep ->
project.copy {
from dep.canonicalPath
into dest
}
}
}

// Hack to trick junit into thinking we have java tests.
testClasses {
dependsOn testCompileEta
task ffigenConfigure {
doLast {
copy {
from zipTree("build/etlas/dist/build/test/test.jar")
into "build/classes/test"
}
// Forward property arguments
System.properties.forEach(new BiConsumer<String, String>() {
void accept(String k, String v) {
ffigen.jvmArgs += "-D$k=$v"
}
})

ffigen.classpath += getIdeaRuntimeClasspath()
ffigen.classpath += project(':ffigen').sourceSets.main.runtimeClasspath
ffigen.classpath += project(':plugin').sourceSets.main.runtimeClasspath
}
}

testClasses.dependsOn(testCompileEta)

task configureTest {
dependsOn testCompileEta
doLast {
test.classpath += files(getEtaRuntimeClasspath())
}
task ffigen(type: JavaExec) {
main = 'com.typelead.intellij.utils.FFIGen'
}

test {
dependsOn configureTest
ffigen.dependsOn(':ffigen:compileJava', ffigenConfigure)

// Adapted from org.jetbrains.intellij.tasks.RunIdeaTask#configureClasspath
FileCollection getIdeaRuntimeClasspath() {
FileCollection cp = project.files()
File ideaDirectory = runIde.ideaDirectory
def toolsJar = Jvm.current().toolsJar
if (toolsJar != null) cp += project.files(toolsJar)
cp += project.files(
"$ideaDirectory/lib/idea_rt.jar",
"$ideaDirectory/lib/idea.jar",
"$ideaDirectory/lib/bootstrap.jar",
"$ideaDirectory/lib/extensions.jar",
"$ideaDirectory/lib/util.jar",
"$ideaDirectory/lib/openapi.jar",
"$ideaDirectory/lib/trove4j.jar",
"$ideaDirectory/lib/jdom.jar",
"$ideaDirectory/lib/log4j.jar"
)
cp
}
2 changes: 1 addition & 1 deletion eta-parser
Submodule eta-parser updated 1 files
+8 −1 tools/hpack
Loading

0 comments on commit 00b1b19

Please sign in to comment.