Chanding logging level individually for task (ScalaCompile)


(Sergey Zh) #1

I’m using gradle to compile scala sources and would like the scala compiler messages to be forwarded to stdout.

Currently this is possible only by running gradle with –info option

Starting process 'Gradle Compiler Daemon 1'. Working directory: /home/user/gradle-scala Command: /opt/jdk1.8.0_40/bin/java -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /home/user/.gradle/caches/2.14/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Compiler Daemon 1'
Successfully started process 'Gradle Compiler Daemon 1'
Started Gradle compiler daemon (0.58 secs) with fork options DaemonForkOptions{minHeapSize=null, maxHeapSize=null, jvmArgs=[], classpath=[/home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.zinc/zinc/0.3.7/6c42a48a9f55f74fae9706083c470c7d8cc512ee/zinc-0.3.7.jar, /home/user/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.4/9aae4cb1802537d604e03688cab744ff47b31a7d/scala-library-2.10.4.jar, /home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.sbt/incremental-compiler/0.13.7/8fae2a4f5eb13f1251f8ea742cb0c859208fa1db/incremental-compiler-0.13.7.jar, /home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.sbt/compiler-interface/0.13.7/1bac4f222551177cd56b8731351f52576960dde/compiler-interface-0.13.7-sources.jar, /home/user/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-compiler/2.10.4/9e65406822299d082caae78699bb4b64011340ef/scala-compiler-2.10.4.jar, /home/user/.gradle/caches/modules-2/files-2.1/com.typesafe.sbt/sbt-interface/0.13.7/2b4ca028f20dd4fccfc134563190f7ef18c4c946/sbt-interface-0.13.7.jar, /home/user/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-reflect/2.10.4/dad1949e8bddc4f97a77025e67d6f0bb2a5071be/scala-reflect-2.10.4.jar]}.
Executing org.gradle.api.internal.tasks.scala.ZincScalaCompiler@37a58d99 in compiler daemon.
Compiling with Zinc Scala compiler.
Compiling 9 Scala sources to /home/user/gradle-scala/target/classes/main...
/home/gradle-scala/src/main/scala/Sample1.scala:280: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T =>
                     ^
/home/gradle-scala/src/main/scala/Sample1.scala:301: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T if attr.get("id") == attrId => Option(attr)
                     ^
/home/gradle-scala/src/main/scala/Sample2.scala:262: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T =>
                     ^
/home/gradle-scala/src/main/scala/Sample2.scala:274: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T if attr.get("id") == attrId => Option(attr)
                     ^
four warnings found
Successfully executed org.gradle.api.internal.tasks.scala.ZincScalaCompiler@37a58d99 in compiler daemon.

… but –info option logs info messages for all other tasks.

And here is how the output looks like without –info

/home/gradle-scala/src/main/scala/Sample1.scala:280: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T =>
                     ^
/home/gradle-scala/src/main/scala/Sample1.scala:301: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T if attr.get("id") == attrId => Option(attr)
                     ^
/home/gradle-scala/src/main/scala/Sample2.scala:262: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T =>
                     ^
/home/gradle-scala/src/main/scala/Sample2.scala:274: abstract type pattern T is unchecked since it is eliminated by erasure
          case attr: T if attr.get("id") == attrId => Option(attr)
                     ^
four warnings found

What I’d like to achieve is to enable –info option for ScalaCompile task only.
Is it somehow possible?