Skip to content

Commit

Permalink
Support the case when webpack project is not in the same root as grad…
Browse files Browse the repository at this point in the history
…le's one.
  • Loading branch information
shafirov committed Aug 9, 2016
1 parent eb0fe85 commit 2f65ea0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/main/groovy/KWP.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 5,12 @@ import org.gradle.api.artifacts.ProjectDependency
import java.util.zip.ZipFile

class KWP implements Plugin<Project> {
private static def loaderText = KWP.class.getResourceAsStream("/kwp.js").text

@Override
void apply(Project target) {
def rootProject = target.rootProject
def targetDir = new File(rootProject.buildDir, "kwp")
def loaderText = getClass().getResourceAsStream("/kwp.js").text

rootProject.afterEvaluate {
targetDir.mkdirs()
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/kwp.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 18,10 @@ module.exports = function(content) {
}

var buildFile = path.resolve(loader.resourcePath);
var root = path.relative(buildFile, "../")
var project = loader.resourceQuery.substr(1)

var gradle = "./gradlew"
var gradle = path.join(root, "gradlew")
if (isWin) {
gradle = ".bat"
}
Expand Down Expand Up @@ -48,7 49,7 @@ module.exports = function(content) {
}
else {
// console.log(stdout)
var deps = fs.readFileSync(path.resolve('build/kwp/__deps.txt'), "UTF-8").split("\n")
var deps = fs.readFileSync(path.join(root, 'build/kwp/__deps.txt'), "UTF-8").split("\n")

for (var i = 0; i < deps.length; i ) {
var t = deps[i].trim()
Expand All @@ -57,7 58,7 @@ module.exports = function(content) {
}
}

success(fs.readFileSync(path.resolve('build/kwp/__modules.js'), "UTF-8"))
success(fs.readFileSync(path.join(root, 'build/kwp/__modules.js'), "UTF-8"))
console.timeEnd("Done Gradle")
}
})
Expand Down

0 comments on commit 2f65ea0

Please sign in to comment.