Skip to content

Commit

Permalink
remove dependency on Gradle internal class
Browse files Browse the repository at this point in the history
restores compatibility with Gradle 2.5
  • Loading branch information
oehme committed Jul 15, 2015
1 parent a207ed4 commit 18de60a
Showing 1 changed file with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.xtext.gradle.idea.tasks
import groovy.lang.Closure
import java.io.File
import java.util.List
import java.util.concurrent.Callable
import org.eclipse.xtend.lib.annotations.Accessors
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.internal.file.collections.LazilyInitializedFileCollection

import static extension org.xtext.gradle.idea.tasks.GradleExtensions.*

Expand All @@ -19,13 +19,13 @@ class IdeaExtension {
String ideaVersion
DownloadIdea downloadIdea
DownloadIdeaPlugins downloadPlugins

new (Project project) {
this.project = project
pluginRepositories = new IdeaPluginRepositories
pluginDependencies = new IdeaPluginDependencies
}

def List<Object> getIdeaLibs() {
val result = <Object>newArrayList
result += pluginDependencies.projectDependencies.map [
Expand All @@ -34,10 +34,10 @@ class IdeaExtension {
result.add(externalLibs)
result
}

def FileCollection getExternalLibs() {
new LazilyInitializedFileCollection {
override createDelegate() {
project.files(new Callable<FileCollection> () {
override call() throws Exception {
val unpackedDependencies = pluginDependencies.externalDependencies.map[
pluginsCache / id / version
]
Expand All @@ -50,84 +50,82 @@ class IdeaExtension {
#[ideaCoreLibs, dependencyClasses, dependencyLibs].filterNull.reduce[a, b| a.plus(b)]
}

override getBuildDependencies() {
[#{downloadIdea, downloadPlugins}]
}
}
})
.builtBy(downloadIdea, downloadPlugins)
}

def FileCollection getIdeaCoreLibs() {
project.fileTree(getIdeaHome + "/lib")
.builtBy(downloadIdea).include("*.jar") as FileCollection
}

def FileCollection getIdeaRunClasspath() {
ideaCoreLibs.plus(toolsJar)
}

def toolsJar() {
project.files('''«System.getProperty("java.home")»/../lib/tools.jar''')
}

def File getIdeaHome() {
if (ideaHome == null) {
project.gradle.gradleUserHomeDir / "ideaSDK" / ideaVersion
} else {
project.file(ideaHome)
project.file(ideaHome)
}
}

def File getPluginsCache() {
project.gradle.gradleUserHomeDir / "ideaPluginDependencies"
}

def File getSourcesZip() {
getIdeaHome / 'sources.zip'
}

def File getSandboxDir() {
project.buildDir / "ideaSandbox"
}

def pluginDependencies(Closure<Void> config) {
project.configure(pluginDependencies as Object, config)
}

def pluginRepositories(Closure<Void> config) {
project.configure(pluginRepositories as Object, config)
}
}

class IdeaPluginRepositories implements Iterable<IdeaPluginRepository> {
val repositories = <IdeaPluginRepository>newTreeSet[$0.url.compareTo($1.url)]

def void url(String url) {
repositories += new IdeaPluginRepository(url)
}

override iterator() {
repositories.iterator
}
}

class IdeaPluginDependencies {

val dependencies = <IdeaPluginDependency>newTreeSet[$0.id.compareTo($1.id)]

def IdeaPluginDependency id(String id) {
val dependency = new IdeaPluginDependency(id)
dependencies += dependency
dependency
}

def project(String id) {
id(id)
}

def getExternalDependencies() {
dependencies.filter[version != null]
}

def getProjectDependencies() {
dependencies.filter[version == null]
}
Expand All @@ -142,8 +140,8 @@ class IdeaPluginRepository {
class IdeaPluginDependency {
val String id
String version

def version(String version) {
this.version = version
}
}
}

0 comments on commit 18de60a

Please sign in to comment.