Skip to content

Commit

Permalink
gradle 2.5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
oehme committed Aug 13, 2015
1 parent c2f4530 commit 055a787
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ class GradleExtensions {
static def + (FileCollection first, FileCollection second) {
first.plus(second)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ package org.xtend.gradle.tasks

import java.net.URLClassLoader
import java.util.regex.Pattern
import org.eclipse.xtend.lib.annotations.Delegate
import org.gradle.api.Buildable
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.file.FileCollection
import org.gradle.api.internal.file.collections.MinimalFileSet
import org.gradle.api.invocation.Gradle

import static org.xtend.gradle.tasks.XtendRuntime.*

import static extension org.xtend.gradle.GradleExtensions.*
import java.util.concurrent.Callable

class XtendRuntime {
static val XTEND_LIB_PATTERN = Pattern.compile("org.eclipse.(xtend|xtext.xbase).(core|lib|lib.slim|lib.gwt)-(\\d.*?).jar")
Expand All @@ -24,10 +20,8 @@ class XtendRuntime {
}

def FileCollection inferXtendClasspath(FileCollection classpath) {
new LazyFileCollection() {

override createDelegate() {
for (file : classpath) {
project.files([|
for (file : classpath) {
val matcher = XTEND_LIB_PATTERN.matcher(file.name)
if (matcher.matches) {
val xtendVersion = matcher.group(3)
Expand All @@ -47,41 +41,14 @@ class XtendRuntime {
}
throw new GradleException(
'''Could not infer Xtend classpath, because no Xtend jar was found on the «classpath» classpath''')
}

override getBuildDependencies() {
switch (classpath) {
Buildable: classpath.buildDependencies
default: [#{}]
}
}
}
] as Callable<FileCollection>)
.builtBy(classpath.buildDependencies)
}

private def getPluginVersion() {
this.class.package.implementationVersion
}

private static abstract class LazyFileCollection implements FileCollection, MinimalFileSet {
var FileCollection delegate

@Delegate def FileCollection getDelegate() {
if (delegate == null)
delegate = createDelegate
delegate
}

def FileCollection createDelegate()

override getDisplayName() {
switch (delegate) {
MinimalFileSet: delegate.displayName
default: delegate.toString
}
}

}

private static val currentCompilerClassLoader = new ThreadLocal<URLClassLoader>() {
override protected initialValue() {
null
Expand Down

0 comments on commit 055a787

Please sign in to comment.