使用gradle定义生成器代码位置以构建xtext和xtend

时间:2018-03-15 09:21:04

标签: gradle xtext xtend

我正在尝试使用带有gradle的xText和xTend构建创建第一个项目。

我按照xText文档中的指导创建了语法,并创建了xtend生成器。

在eclipse中,代码按预期生成到src-gen文件夹。

当我创建gradle脚本时,也按照http://xtext.github.io/xtext-gradle-plugin/xtext-builder.html构建我的代码,而不是在'src-gen'文件夹中生成代码,它在'build'文件夹中生成。

有没有办法在gradle中将此文件夹从build更改为src-gen?我尝试了很多东西而且总是出错。

完整的成绩脚本代码:

18/03/15 10:52:07 INFO client.RMProxy: Connecting to ResourceManager at master/172.30.10.64:8050
18/03/15 10:52:07 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Application Report : 
    Application-Id : application_1521023754917_0007
    Application-Name : count.py
    Application-Type : SPARK
    User : hduser
    Queue : default
    Start-Time : 1521105214408
    Finish-Time : 1521105231067
    Progress : 0%
    State : FAILED
    Final-State : FAILED
    Tracking-URL : http://master:8088/cluster/app/application_1521023754917_0007
    RPC Port : -1
    AM Host : N/A
    Aggregate Resource Allocation : 16329 MB-seconds, 15 vcore-seconds
    Diagnostics : Application application_1521023754917_0007 failed 2 times due to AM Container for appattempt_1521023754917_0007_000002 exited with  exitCode: -103
For more detailed output, check application tracking page:http://master:8088/cluster/app/application_1521023754917_0007Then, click on links to logs of each attempt.
Diagnostics: Container [pid=9363,containerID=container_1521023754917_0007_02_000001] is running beyond virtual memory limits. Current usage: 147.7 MB of 1 GB physical memory used; 2.1 GB of 2.1 GB virtual memory used. Killing container.
Dump of the process-tree for container_1521023754917_0007_02_000001 :
    |- PID PPID PGRPID SESSID CMD_NAME USER_MODE_TIME(MILLIS) SYSTEM_TIME(MILLIS) VMEM_USAGE(BYTES) RSSMEM_USAGE(PAGES) FULL_CMD_LINE
    |- 9369 9363 9363 9363 (java) 454 16 2250776576 37073 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -server -Xmx512m -Djava.io.tmpdir=/tmp/hadoop-hduser/nm-local-dir/usercache/hduser/appcache/application_1521023754917_0007/container_1521023754917_0007_02_000001/tmp -Dspark.yarn.app.container.log.dir=/usr/local/hadoop-2.7.5/logs/userlogs/application_1521023754917_0007/container_1521023754917_0007_02_000001 org.apache.spark.deploy.yarn.ExecutorLauncher --arg master:40388 --properties-file /tmp/hadoop-hduser/nm-local-dir/usercache/hduser/appcache/application_1521023754917_0007/container_1521023754917_0007_02_000001/__spark_conf__/__spark_conf__.properties 
    |- 9363 9361 9363 9363 (bash) 0 0 12869632 742 /bin/bash -c /usr/lib/jvm/java-8-openjdk-amd64/bin/java -server -Xmx512m -Djava.io.tmpdir=/tmp/hadoop-hduser/nm-local-dir/usercache/hduser/appcache/application_1521023754917_0007/container_1521023754917_0007_02_000001/tmp -Dspark.yarn.app.container.log.dir=/usr/local/hadoop-2.7.5/logs/userlogs/application_1521023754917_0007/container_1521023754917_0007_02_000001 org.apache.spark.deploy.yarn.ExecutorLauncher --arg 'master:40388' --properties-file /tmp/hadoop-hduser/nm-local-dir/usercache/hduser/appcache/application_1521023754917_0007/container_1521023754917_0007_02_000001/__spark_conf__/__spark_conf__.properties 1> /usr/local/hadoop-2.7.5/logs/userlogs/application_1521023754917_0007/container_1521023754917_0007_02_000001/stdout 2> /usr/local/hadoop-2.7.5/logs/userlogs/application_1521023754917_0007/container_1521023754917_0007_02_000001/stderr 

Container killed on request. Exit code is 143
Container exited with a non-zero exit code 143
Failing this attempt. Failing the application.

1 个答案:

答案 0 :(得分:2)

您可以在源集中配置

sourceSets {
   main.xtendOutputDir = 'xtend-gen'
}

e.g。

plugins {
  id "org.xtext.xtend" version "1.0.21"
}

apply plugin: 'java'
apply plugin: 'org.xtext.xtend'

sourceSets {
  main.java.srcDirs = ['src','xtend-gen']
  main.xtendOutputDir = 'xtend-gen'
}

repositories {
    jcenter()
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    compile 'org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.13.0'

}

或用于xtxt构建器插件

buildscript {
    repositories {
        mavenLocal()
            jcenter()
    }
    dependencies {
        classpath 'org.xtext:xtext-gradle-plugin:1.0.21'
    }
}
plugins {
    id "org.xtext.builder" version "1.0.21"
}

repositories {
    mavenLocal()
    jcenter()
}

dependencies {
    xtextLanguages 'org.xtext.example.mydslfoo:org.xtext.example.mydslfoo:1.0.0-SNAPSHOT'
}

xtext {
    version '2.13.0'
    languages {
        mydslfoo {
            setup = 'org.xtext.example.mydslfoo.MyDslFooStandaloneSetup'
            generator {
                outlets {
                    HEROES {              
                    }
                    }
            }
        }
    }
    sourceSets {
        main {
            srcDir 'src'
            output {
                dir(xtext.languages.mydslfoo.generator.outlet, 'src-gen')
                }
        }
    }
  }