-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from xtext/incremental_build
Incremental build
- Loading branch information
Showing
84 changed files
with
3,578 additions
and
846 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
.classpath | ||
.project | ||
.settings/ | ||
.gradle/ | ||
# Eclipse | ||
.classpath | ||
.project | ||
.settings/ | ||
.metadata/ | ||
bin/ | ||
|
||
# IntelliJ | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
out/ | ||
|
||
# Gradle | ||
.gradle/ | ||
build/ | ||
|
||
bin/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
language: java | ||
sudo: false | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
cache: | ||
directories: | ||
- $HOME/.gradle | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ | ||
install: true | ||
script: ./gradlew check && ./.travis/releaseOnTag.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,8 @@ | ||
xtext-gradle-plugin | ||
Xtext Gradle Plugins | ||
=================== | ||
|
||
[![Build Status](https://travis-ci.org/xtext/xtext-gradle-plugin.svg?branch=master)](https://travis-ci.org/xtext/xtext-gradle-plugin) | ||
|
||
A plugin for using Xtext languages from a Gradle build | ||
A set of [Gradle](gradle.org) plugins to build and use [Xtext](xtext.org) languages and the [Xtend](xtend-lang.org) programming language. | ||
|
||
Features | ||
-------- | ||
|
||
- Use Xtext based code generators in your Gradle build | ||
- automatically integrates with the Java plugin | ||
- all your languages are built in one go, so they can have cross-references | ||
- configures the Eclipse plugin to generate .settings files for each language | ||
|
||
Usage | ||
----- | ||
|
||
Get the latest version of the plugin from the [Gradle Plugin Portal](http://plugins.gradle.org/plugin/org.xtext.xtext) | ||
|
||
Add your languages to the xtextTooling configuration | ||
|
||
```groovy | ||
dependencies { | ||
xtextTooling 'org.example:org.example.hero.core:3.3.3' | ||
xtextTooling 'org.example:org.example.villain.core:6.6.6' | ||
} | ||
``` | ||
|
||
Add code that your models compile against to the xtext configuration. If you use the Java plugin, this configuration will automatically contain everything from compile and testCompile. So in many cases this can be omitted. | ||
|
||
```groovy | ||
dependencies { | ||
xtext 'com.google.guava:guava:15.0' | ||
} | ||
``` | ||
|
||
Configure your languages | ||
|
||
```groovy | ||
xtext { | ||
version = '2.8.0' // the current default, can be omitted | ||
encoding = 'UTF-8' //the default, can be omitted | ||
/* Java sourceDirs are added automatically, | ||
* so you only need this element if you have | ||
* additional source directories to add | ||
*/ | ||
sources { | ||
srcDir 'src/main/heroes' | ||
srcDir 'src/main/villains' | ||
} | ||
languages{ | ||
heroes { | ||
setup = 'org.example.hero.core.HeroStandaloneSetup' | ||
consumesJava = true | ||
outputs { | ||
DEFAULT_OUTPUT.dir = 'build/heroes' | ||
SIDEKICKS { | ||
dir = 'build/sidekicks' | ||
//automatically adds the above folder as a Java source folder for the main sourceSet | ||
producesJavaFor sourceSets.main | ||
} | ||
} | ||
} | ||
villains { | ||
setup = 'org.example.villain.core.VillainStandaloneSetup' | ||
//equivalent to DEFAULT_OUTPUT.dir | ||
output.dir = 'build/villains' | ||
} | ||
} | ||
} | ||
``` | ||
The documentation is hosted on the [project's website](http://xtext.github.io/xtext-gradle-plugin/). |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Tue Jun 03 18:49:02 CEST 2014 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-bin.zip | ||
#Tue Jun 03 18:49:02 CEST 2014 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-2.7-all.zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include 'xtext-gradle-lib', 'xtext-gradle-plugin', 'xtext-idea-gradle-plugin' | ||
include 'xtext-gradle-protocol', 'xtext-gradle-builder', 'xtext-gradle-plugin', 'xtext-idea-gradle-plugin', 'xtext-android-gradle-plugin' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
description 'A plugin for integrating Xtext based Code generators with the Android build tools' | ||
|
||
dependencies { | ||
compile project(':xtext-gradle-plugin') | ||
compile 'com.android.tools.build:gradle:1.5.0' | ||
integTestCompile project(path : ':xtext-gradle-plugin', configuration: 'integTestCompile') | ||
} | ||
|
||
integrationTest { | ||
dependsOn(':xtext-gradle-builder:install', ':xtext-gradle-protocol:install', ':xtext-gradle-plugin:install') | ||
} |
25 changes: 25 additions & 0 deletions
25
...roid-gradle-plugin/src/main/java/org/xtext/gradle/android/XtendAndroidBuilderPlugin.xtend
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.xtext.gradle.android | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.xtext.gradle.XtendLanguageBasePlugin | ||
import org.xtext.gradle.protocol.GradleInstallDebugInfoRequest.SourceInstaller | ||
import org.xtext.gradle.tasks.XtextExtension | ||
|
||
class XtendAndroidBuilderPlugin implements Plugin<Project> { | ||
|
||
override apply(Project project) { | ||
project.apply[ | ||
plugin(XtextAndroidBuilderPlugin) | ||
plugin(XtendLanguageBasePlugin) | ||
] | ||
|
||
val xtext = project.extensions.getByType(XtextExtension) | ||
xtext.languages.getAt("xtend") => [ | ||
debugger => [ | ||
sourceInstaller = SourceInstaller.PRIMARY | ||
hideSyntheticVariables = false | ||
] | ||
] | ||
} | ||
} |
107 changes: 107 additions & 0 deletions
107
...roid-gradle-plugin/src/main/java/org/xtext/gradle/android/XtextAndroidBuilderPlugin.xtend
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package org.xtext.gradle.android | ||
|
||
import com.android.build.gradle.AppExtension | ||
import com.android.build.gradle.AppPlugin | ||
import com.android.build.gradle.BaseExtension | ||
import com.android.build.gradle.LibraryExtension | ||
import com.android.build.gradle.LibraryPlugin | ||
import com.android.build.gradle.api.BaseVariant | ||
import com.android.build.gradle.internal.api.TestedVariant | ||
import java.io.File | ||
import org.gradle.api.DomainObjectSet | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.xtext.gradle.XtextBuilderPlugin | ||
import org.xtext.gradle.XtextJavaLanguagePlugin | ||
import org.xtext.gradle.tasks.XtextExtension | ||
import org.xtext.gradle.tasks.XtextGenerate | ||
|
||
class XtextAndroidBuilderPlugin implements Plugin<Project> { | ||
|
||
Project project | ||
XtextExtension xtext | ||
BaseExtension android | ||
DomainObjectSet<? extends BaseVariant> variants | ||
|
||
override apply(Project project) { | ||
this.project = project | ||
project.apply[ | ||
plugin(XtextBuilderPlugin) | ||
plugin(XtextJavaLanguagePlugin) | ||
] | ||
xtext = project.extensions.getByType(XtextExtension) | ||
project.plugins.withType(AppPlugin)[configureAndroid] | ||
project.plugins.withType(LibraryPlugin)[configureAndroid] | ||
} | ||
|
||
private def configureAndroid() { | ||
project.afterEvaluate[ | ||
android = project.extensions.getByName("android") as BaseExtension | ||
variants = switch android { | ||
AppExtension: android.applicationVariants as DomainObjectSet<? extends BaseVariant> | ||
LibraryExtension: android.libraryVariants | ||
default: throw new GradleException('''Unknown packaging type «android.class.simpleName»''') | ||
} | ||
configureOutletDefaults | ||
configureGeneratorDefaults | ||
configureSourceSetDefaults | ||
] | ||
} | ||
|
||
private def configureSourceSetDefaults() { | ||
variants.all [ variant | | ||
configureSourceSetForVariant(variant) | ||
if (variant instanceof TestedVariant) { | ||
if (variant.testVariant != null) | ||
configureSourceSetForVariant(variant.testVariant) | ||
} | ||
] | ||
} | ||
|
||
private def configureSourceSetForVariant(BaseVariant variant) { | ||
xtext.sourceSets.maybeCreate(variant.name) => [ sourceSet | | ||
val generatorTask = project.tasks.getByName(sourceSet.generatorTaskName) as XtextGenerate | ||
generatorTask.dependsOn( | ||
variant.aidlCompile, | ||
variant.renderscriptCompile, | ||
variant.generateBuildConfig | ||
) | ||
generatorTask.dependsOn(variant.outputs.map[processResources]) | ||
variant.javaCompiler.doLast[generatorTask.installDebugInfo] | ||
val sourceDirs = newArrayList | ||
val javaDirs = variant.sourceSets.map[javaDirectories].flatten.filter[directory] | ||
sourceDirs += javaDirs | ||
sourceDirs += #[ | ||
variant.aidlCompile.sourceOutputDir, | ||
variant.generateBuildConfig.sourceOutputDir, | ||
variant.renderscriptCompile.sourceOutputDir | ||
] | ||
sourceDirs += variant.outputs.map[processResources.sourceOutputDir] | ||
sourceSet.srcDirs(sourceDirs) | ||
generatorTask.bootClasspath = android.bootClasspath.join(File.pathSeparator) | ||
generatorTask.classpath = variant.javaCompiler.classpath.plus(project.files(android.bootClasspath)) | ||
generatorTask.classesDir = variant.javaCompiler.destinationDir | ||
generatorTask.options.encoding = android.compileOptions.encoding | ||
variant.registerJavaGeneratingTask(generatorTask, generatorTask.outputDirectories) | ||
] | ||
} | ||
|
||
private def configureGeneratorDefaults() { | ||
xtext.languages.all [ | ||
generator.javaSourceLevel = android.compileOptions.sourceCompatibility.toString | ||
] | ||
} | ||
|
||
private def configureOutletDefaults() { | ||
xtext.languages.all [ language | | ||
language.generator.outlets.all [ outlet | | ||
xtext.sourceSets.all [ sourceSet | | ||
val output = sourceSet.output | ||
output.dir(outlet, '''«project.buildDir»/generated/source/«language.name»«outlet.folderFragment»/«sourceSet.name»''') | ||
] | ||
] | ||
] | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...le-plugin/src/main/resources/META-INF/gradle-plugins/org.xtext.android.builder.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
implementation-class=org.xtext.gradle.android.XtextAndroidBuilderPlugin |
1 change: 1 addition & 0 deletions
1
...adle-plugin/src/main/resources/META-INF/gradle-plugins/org.xtext.android.xtend.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
implementation-class=org.xtext.gradle.android.XtendAndroidBuilderPlugin |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
description 'A small wrapper for Xtext to make it easier to use from Gradle' | ||
|
||
dependencies { | ||
compile "org.eclipse.xtext:org.eclipse.xtext:2.9.0" | ||
compile "org.eclipse.xtext:org.eclipse.xtext.java:2.9.0" | ||
compile "org.eclipse.xtext:org.eclipse.xtext.xbase:2.9.0" | ||
compile project(':xtext-gradle-protocol') | ||
} |
Oops, something went wrong.