-
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.
added IDEA plugin, ported to Xtext 2.8
- Loading branch information
Showing
25 changed files
with
509 additions
and
61 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
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,47 +1,54 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'org.xtend:xtend-gradle-plugin:0.4.3' | ||
classpath 'com.github.oehme.sobula:sobula:0.4.1' | ||
} | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'org.xtend:xtend-gradle-plugin:0.4.5' | ||
classpath 'com.github.oehme.sobula:sobula:0.4.2' | ||
} | ||
} | ||
|
||
/* | ||
* TODO this weird order is a workaround for a bug in the nebula publishing plugin | ||
* If they don't fix it soon, sobula should be rewritten to work without it. | ||
*/ | ||
configure(subprojects.findAll{p-> p.name.contains('plugin')}){ | ||
apply plugin: 'org.xtend.xtend' | ||
apply plugin: 'com.github.oehme.sobula.plugin-release' | ||
apply plugin: 'java-gradle-plugin' | ||
|
||
dependencies { | ||
compile 'org.eclipse.xtend:org.eclipse.xtend.lib:2.8.0' | ||
} | ||
} | ||
|
||
subprojects { | ||
apply plugin: 'java' | ||
apply plugin: 'eclipse' | ||
apply plugin: 'com.github.oehme.sobula.bintray-release' | ||
apply plugin: 'com.github.oehme.sobula.stefan' | ||
apply plugin: 'eclipse' | ||
apply plugin: 'java' | ||
|
||
sourceCompatibility = 1.6 | ||
} | ||
|
||
group = "org.xtext" | ||
bintray.pkg.name = "$project.group:$project.name" | ||
|
||
contacts { | ||
"[email protected]" { | ||
moniker "The Xtext team" | ||
roles "owner" | ||
github "xtext" | ||
} | ||
} | ||
allprojects { | ||
apply plugin: 'com.github.oehme.sobula.bintray-release' | ||
|
||
group = "org.xtext" | ||
bintray.pkg.name = "$rootProject.group:$rootProject.name" | ||
|
||
contacts { | ||
"[email protected]" { | ||
moniker "The Xtext team" | ||
roles "owner" | ||
github "xtext" | ||
} | ||
} | ||
|
||
//TODO create bintray and central users | ||
bintray.user = "oehme" | ||
bintray.pkg.version.mavenCentralSync.user = "oehme" | ||
|
||
repositories { | ||
//TODO create bintray and central users | ||
bintray.user = "oehme" | ||
bintray.pkg.version.mavenCentralSync.user = "oehme" | ||
repositories { | ||
jcenter() | ||
} | ||
|
||
sourceCompatibility = 1.5 | ||
} | ||
|
||
configure(subprojects.findAll{p-> p.name.contains('plugin')}){ | ||
apply plugin: 'com.github.oehme.sobula.plugin-release' | ||
apply plugin: 'java-gradle-plugin' | ||
apply plugin: 'org.xtend.xtend' | ||
|
||
dependencies { | ||
compile 'org.eclipse.xtend:org.eclipse.xtend.lib:2.7.3' | ||
} | ||
} | ||
bintray.publications = [] // don't publish a POM for the root project |
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 +1 @@ | ||
include 'xtext-gradle-lib', 'xtext-gradle-plugin' | ||
include 'xtext-gradle-lib', 'xtext-gradle-plugin', 'xtext-idea-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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
description 'A small wrapper for Xtext to make it easier to use from Gradle' | ||
|
||
dependencies { | ||
compile ("org.eclipse.xtext:org.eclipse.xtext.builder.standalone:[2.5.4,)") { | ||
compile ("org.eclipse.xtext:org.eclipse.xtext.builder.standalone:[2.8.0,)") { | ||
exclude group:'asm', module:'asm' | ||
} | ||
} |
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
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,3 @@ | ||
.settings/ | ||
.project | ||
.classpath |
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,5 @@ | ||
description 'A plugin for for building IntelliJ IDEA Xtext plugins' | ||
|
||
dependencies { | ||
compile 'org.apache.httpcomponents:httpclient:4.4' | ||
} |
55 changes: 55 additions & 0 deletions
55
xtext-idea-gradle-plugin/src/main/java/org/xtext/gradle/idea/IdeaComponentPlugin.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,55 @@ | ||
package org.xtext.gradle.idea | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPlugin | ||
import org.gradle.api.plugins.JavaPluginConvention | ||
import org.gradle.plugins.ide.eclipse.model.Classpath | ||
import org.gradle.plugins.ide.eclipse.model.EclipseModel | ||
import org.gradle.plugins.ide.eclipse.model.Library | ||
import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory | ||
import org.xtext.gradle.idea.tasks.DownloadIdea | ||
|
||
import static extension org.xtext.gradle.idea.tasks.GradleExtensions.* | ||
import org.gradle.plugins.ide.eclipse.EclipsePlugin | ||
|
||
class IdeaComponentPlugin implements Plugin<Project> { | ||
|
||
override apply(Project project) { | ||
project.plugins.<IdeaDevelopmentPlugin>apply(IdeaDevelopmentPlugin) | ||
project.plugins.<JavaPlugin>apply(JavaPlugin) | ||
|
||
val compile = project.configurations.getAt("compile") | ||
compile.exclude(#{"module" -> "guava"}) | ||
compile.exclude(#{"module" -> "log4j"}) | ||
|
||
val ideaProvided = project.configurations.create("ideaProvided") | ||
|
||
project.afterEvaluate [ | ||
val downloadTask = project.tasks.getByName("downloadIdea") as DownloadIdea | ||
val ideaHomeDir = downloadTask.ideaHomeDir | ||
|
||
val ideaLibs = project.fileTree(ideaHomeDir + "/lib").builtBy(downloadTask).include("*.jar") | ||
project.dependencies.add(ideaProvided.name, ideaLibs) | ||
project.convention.getPlugin(JavaPluginConvention).sourceSets.forEach [ | ||
compileClasspath = compileClasspath.plus(ideaProvided) | ||
] | ||
|
||
project.plugins.withType(EclipsePlugin) [ | ||
project.tasks.getByName("eclipseClasspath").dependsOn(downloadTask) | ||
project.extensions.getByType(EclipseModel).classpath => [ | ||
plusConfigurations.add(ideaProvided) | ||
|
||
val fileReferenceFactory = new FileReferenceFactory | ||
file.whenMerged.add [ Classpath it | | ||
val sourceZip = ideaHomeDir / "sources.zip" | ||
entries.filter(Library).filter[library.file.parentFile == ideaHomeDir / 'lib'].forEach [ | ||
sourcePath = fileReferenceFactory.fromFile(sourceZip) | ||
] | ||
] | ||
] | ||
] | ||
] | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
xtext-idea-gradle-plugin/src/main/java/org/xtext/gradle/idea/IdeaDevelopmentPlugin.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,24 @@ | ||
package org.xtext.gradle.idea | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.xtext.gradle.idea.tasks.DownloadIdea | ||
import org.xtext.gradle.idea.tasks.IdeaExtension | ||
|
||
import static extension org.xtext.gradle.idea.tasks.GradleExtensions.* | ||
|
||
class IdeaDevelopmentPlugin implements Plugin<Project> { | ||
|
||
override apply(Project project) { | ||
val idea = project.extensions.create("ideaDevelopment", IdeaExtension) => [ | ||
ideaHome = project.rootDir / "ideaHome" | ||
ideaVersion = "140.2683.2" | ||
sandboxDir = project.rootProject.buildDir / "ideaSandbox" | ||
] | ||
val downloadTask = project.tasks.create("downloadIdea", DownloadIdea) | ||
project.afterEvaluate [ | ||
downloadTask.ideaHome = idea.ideaHome | ||
downloadTask.ideaVersion = idea.ideaVersion | ||
] | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
xtext-idea-gradle-plugin/src/main/java/org/xtext/gradle/idea/IdeaPluginPlugin.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,36 @@ | ||
package org.xtext.gradle.idea | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginConvention | ||
import org.xtext.gradle.idea.tasks.AssembleSandbox | ||
import org.xtext.gradle.idea.tasks.IdeaExtension | ||
import org.xtext.gradle.idea.tasks.IdeaZip | ||
|
||
import static extension org.xtext.gradle.idea.tasks.GradleExtensions.* | ||
import org.gradle.api.Action | ||
import org.xtext.gradle.idea.tasks.IdeaPluginSpec | ||
|
||
class IdeaPluginPlugin implements Plugin<Project> { | ||
override apply(Project project) { | ||
project.plugins.<IdeaComponentPlugin>apply(IdeaComponentPlugin) | ||
val idea = project.extensions.getByType(IdeaExtension) | ||
val mainSourceSet = project.convention.getPlugin(JavaPluginConvention).sourceSets.getByName("main") | ||
val providedDependencies = project.configurations.getAt("ideaProvided") | ||
val runtimeDependencies = project.configurations.getAt("runtime") | ||
|
||
val Action<? super IdeaPluginSpec> archiveConfig = [ | ||
classes.from(mainSourceSet.output) | ||
libraries.from(runtimeDependencies.minus(providedDependencies)) | ||
metaInf.from("META-INF") | ||
] | ||
|
||
project.tasks.create("ideaZip", IdeaZip, archiveConfig) | ||
|
||
val assembleSandboxTask = project.tasks.create("assembleSandbox", AssembleSandbox, archiveConfig) | ||
|
||
project.afterEvaluate [ | ||
assembleSandboxTask.destinationDir = project.file(idea.sandboxDir) / project.name | ||
] | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
xtext-idea-gradle-plugin/src/main/java/org/xtext/gradle/idea/IdeaRepositoryPlugin.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,39 @@ | ||
package org.xtext.gradle.idea | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.xtext.gradle.idea.tasks.AssembleSandbox | ||
import org.xtext.gradle.idea.tasks.DownloadIdea | ||
import org.xtext.gradle.idea.tasks.IdeaExtension | ||
import org.xtext.gradle.idea.tasks.IdeaRepository | ||
import org.xtext.gradle.idea.tasks.IdeaZip | ||
import org.xtext.gradle.idea.tasks.RunIdea | ||
|
||
import static extension org.xtext.gradle.idea.tasks.GradleExtensions.* | ||
|
||
class IdeaRepositoryPlugin implements Plugin<Project> { | ||
|
||
override apply(Project project) { | ||
project.plugins.<IdeaDevelopmentPlugin>apply(IdeaDevelopmentPlugin) | ||
val idea = project.extensions.getByType(IdeaExtension) | ||
val repositoryTask = project.tasks.create("ideaRepository", IdeaRepository) [ | ||
into(project.buildDir / 'ideaRepository') | ||
] | ||
project.allprojects [ | ||
tasks.withType(IdeaZip) [ zip | | ||
repositoryTask.from(zip) | ||
] | ||
] | ||
val runIdea = project.tasks.create("runIdea", RunIdea) | ||
val downloadTask = project.tasks.getAt("downloadIdea") as DownloadIdea | ||
project.afterEvaluate [ | ||
val ideaLibs = project.fileTree(downloadTask.ideaHomeDir + "/lib") | ||
ideaLibs.builtBy(downloadTask).include("*.jar") | ||
subprojects.map[tasks.withType(AssembleSandbox)].flatten.forEach[runIdea.dependsOn(it)] | ||
runIdea.sandboxDir = project.file(idea.sandboxDir) | ||
runIdea.ideaHome = project.file(idea.ideaHome) | ||
val tools = project.files('''«System.getenv("JAVA_HOME")»/lib/tools.jar''') | ||
runIdea.classpath = ideaLibs.plus(tools) | ||
] | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
xtext-idea-gradle-plugin/src/main/java/org/xtext/gradle/idea/tasks/AssembleSandbox.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,18 @@ | ||
package org.xtext.gradle.idea.tasks | ||
|
||
import org.eclipse.xtend.lib.annotations.Accessors | ||
import org.gradle.api.file.CopySpec | ||
import org.gradle.api.tasks.Sync | ||
|
||
@Accessors | ||
class AssembleSandbox extends Sync implements IdeaPluginSpec { | ||
CopySpec classes | ||
CopySpec libraries | ||
CopySpec metaInf | ||
|
||
new() { | ||
classes = rootSpec.addChild.into("classes") | ||
libraries = rootSpec.addChild.into("lib") | ||
metaInf = rootSpec.addChild.into("META-INF") | ||
} | ||
} |
Oops, something went wrong.