[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/javaimp-gradle ff2013c 2/2: Fixes for gradle
From: |
Filipp Gunbin |
Subject: |
[elpa] scratch/javaimp-gradle ff2013c 2/2: Fixes for gradle |
Date: |
Fri, 1 Nov 2019 14:18:50 -0400 (EDT) |
branch: scratch/javaimp-gradle
commit ff2013cfd9e351eadd76bcc85711a3fa30356d7b
Author: Filipp Gunbin <address@hidden>
Commit: Filipp Gunbin <address@hidden>
Fixes for gradle
---
packages/javaimp/getJarsOnlyTaskBody.inc.kts | 8 ------
...InfoTaskBody.inc.kts => gradleTaskBody.inc.kts} | 2 +-
packages/javaimp/javaimp-gradle.el | 32 ++++++++--------------
3 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/packages/javaimp/getJarsOnlyTaskBody.inc.kts
b/packages/javaimp/getJarsOnlyTaskBody.inc.kts
deleted file mode 100644
index 4951255..0000000
--- a/packages/javaimp/getJarsOnlyTaskBody.inc.kts
+++ /dev/null
@@ -1,8 +0,0 @@
-// use syntax which is valid both in Groovy and in Kotlin
-doLast {
- if (project.hasProperty("sourceSets")) {
- println(project.sourceSets.stream()
- .flatMap { it.compileClasspath.files.stream().filter {
it.name.endsWith("jar") }.map { it.path } }
- .collect(Collectors.joining(File.pathSeparator)))
- }
-}
diff --git a/packages/javaimp/getInfoTaskBody.inc.kts
b/packages/javaimp/gradleTaskBody.inc.kts
similarity index 91%
rename from packages/javaimp/getInfoTaskBody.inc.kts
rename to packages/javaimp/gradleTaskBody.inc.kts
index 3aceb9b..10b778c 100644
--- a/packages/javaimp/getInfoTaskBody.inc.kts
+++ b/packages/javaimp/gradleTaskBody.inc.kts
@@ -7,7 +7,7 @@ doLast {
println("file=${project.buildFile}")
println("final-name=${project.archivesBaseName}")
println("build-dir=${project.buildDir}")
- if (project.hasProperty("sourceSets")) {
+ if (project.hasProperty("sourceSets")) { //sourceSets are defined by java
plugin
println("source-dirs=" + project.sourceSets.stream()
.flatMap { it.java.srcDirs.stream().map { it.path } }
.collect(Collectors.joining(File.pathSeparator)))
diff --git a/packages/javaimp/javaimp-gradle.el
b/packages/javaimp/javaimp-gradle.el
index 5728501..285794e 100644
--- a/packages/javaimp/javaimp-gradle.el
+++ b/packages/javaimp/javaimp-gradle.el
@@ -28,17 +28,11 @@ gradlew program, it is used in preference."
:group 'javaimp
:type 'string)
-(defconst javaimp--gradle-get-info-script
+(defconst javaimp--gradle-task-body
(with-temp-buffer
- (insert-file-contents "getInfoTaskBody.inc.kts")
+ (insert-file-contents "gradleTaskBody.inc.kts")
(buffer-string))
- "Task body, uses Java syntax to be reused in both Groovy and Kotlin")
-
-(defconst javaimp--gradle-get-jars-script
- (with-temp-buffer
- (insert-file-contents "getJarsOnlyTaskBody.inc.kts")
- (buffer-string))
- "Task body, uses Java syntax to be reused in both Groovy and Kotlin")
+ "Task body, uses syntax which can be used both in Groovy and Kotlin")
(defun javaimp--gradle-visit (file)
"Calls gradle on FILE to get various project information.
@@ -48,7 +42,7 @@ invokes task contained in it. This task returns all needed
information."
(message "Visiting Gradle build file %s..." file)
(let* ((alists (javaimp--gradle-call file
- javaimp--gradle-get-info-script
+ javaimp--gradle-task-body
#'javaimp--gradle-handler
"javaimpTask"))
(modules (mapcar (lambda (alist)
@@ -100,18 +94,16 @@ information."
(make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version
(nth 2 parts)))))
(defun javaimp--gradle-fetch-dep-jars-path (module)
- ;; always invoke on originating file becase module's file may not
- ;; exist (even if reported as project.buildFile property); also,
- ;; local gradlew which needs to be invoked will usually reside
- ;; alongside top-level build file
+ ;; always invoke on root file becase module's file may not exist
+ ;; (even if reported as project.buildFile property)
(javaimp--gradle-call (javaimp-module-file-orig module)
- javaimp--gradle-get-jars-script
+ javaimp--gradle-task-body
(lambda ()
- ;; expect just a single line
- (thing-at-point 'line))
- (format ":%s:javaimpTask" ;TODO what if root?
- (javaimp-id-artifact (javaimp-module-id
module)))))
-
+ (re-search-forward "^dep-jars=\\(.*\\)$")
+ (match-string 1))
+ (concat (if (javaimp-module-parent-id module)
+ (concat ":" (javaimp-id-artifact
(javaimp-module-id module))))
+ ":javaimpTask")))
(defun javaimp--gradle-call (file init-script-body handler task)
(let* ((is-kotlin (equal (file-name-extension file) "kts"))