How do you actually debug what is going on in SBT

1,060 views
Skip to first unread message

jda...@accesio.com

unread,
Aug 13, 2015, 10:34:10 PM8/13/15
to simple-build-tool
Hi,

I am used to Make / CMake or Ant build systems where I can either type "make -n" and see what is going to happen before it happens, or I can generally enable some sort of debug flag that prints out what low commands are being issued.

I find that SBT ( along with every other Java build tool minus Ant ) makes it too difficult to see what commands are being issued.

How can I turn on extremely low level Debug messages that tell me what  are the actual commands to "javac" ?

Now, I've done this inside sbt

set logLevel := Level.Debug

and then run

compile


but looks what happens when I compile Java: ( I'll save you the headache , but essentially this is all that comes up that is important:

[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set(/media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/main/java/com/FooBar/MainAc
tivity.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-gen/com/FooBar/R.java, /media/jdamon/Development/Docu
ments/Projects/learning_scala/Foo/target/android-gen/com/FooBar/BuildConfig.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo
/src/androidTest/java/com/FooBar/MainActivityTest.java)

[debug]
[debug] Sources indirectly invalidated by:
[debug]         product: Set()
[debug]         binary dep: Set()
[debug]         external source: Set()
[debug] All initially invalidated sources: Set(/media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/main/java/com/FooBar/MainActiv
ity.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-gen/com/FooBar/R.java, /media/jdamon/Development/Documen
ts/Projects/learning_scala/Foo/target/android-gen/com/FooBar/BuildConfig.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/sr
c/androidTest/java/com/FooBar/MainActivityTest.java)
[debug] Recompiling all 4 sources: invalidated sources (4) exceeded 50.0% of all sources
[info] Compiling 4 Java sources to /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-bin/classes...
[debug] Attempting to call javac directly...
[debug] com.sun.tools.javac.Main not found with appropriate method signature; forking javac instead
[debug] Forking javac: javac @/tmp/sbt_11c2da96/argfile


1. How can I make SBT actually show the commands being invoked :  Example, Ant with -verbose will actually show you every single command albeit in a streched out format ( multi-line )


2. Why isn't SBT configured by default so that it shows this information with debug turned on?  To me this is as bad as Eclipse that refuses to show the user the actual compilation steps UNLESS you are an Eclipse super user and no how to enable this ( which I am not and is why I left trying to learn Eclipse ).

An example of a better system is what CMake does where every single compilation phase can be traced to miniature shell scripts that build parts of the design. This way if there are any strange behaviours you can at least get down to the bare metal to explore.

Thanks for any suggestions on how to get into how SBT to list every command it runs explicitly.















[debug] resolving dependencies for configuration 'compile'
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [compile]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->default(compile)]
[info] Resolving org.scala-lang#scala-library;2.10.4 ...
[debug] sbt-chain: Checking cache for: sbt.ivyint.MergedDescriptors@2c68160c
[debug] sbt-chain: module revision found in cache: org.scala-lang#scala-library;2.10.4
[debug]         found org.scala-lang#scala-library;2.10.4 in sbt-chain
[debug]         [2.10.4] org.scala-lang#scala-library;2.10.4
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->runtime]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->compile]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->master]
[debug] resolving dependencies for configuration 'runtime'
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [runtime]
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [compile]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->default(compile)]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->runtime]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->compile]
[debug] == resolving dependencies com-foobar#com-foobar;0.1-SNAPSHOT->org.scala-lang#scala-library;2.10.4 [compile->master]
[debug] resolving dependencies for configuration 'test'
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [test]
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [runtime]
[debug] == resolving dependencies for com-foobar#com-foobar;0.1-SNAPSHOT [compile]
....
[debug] Initial source changes:
[debug]         removed:Set()
[debug]         added: Set(/media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/main/java/com/FooBar/MainActivity.java, /media/jda
mon/Development/Documents/Projects/learning_scala/Foo/target/android-gen/com/FooBar/R.java, /media/jdamon/Development/Documents/Projects/learning
_scala/Foo/target/android-gen/com/FooBar/BuildConfig.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/androidTest/java/c
om/FooBar/MainActivityTest.java)
[debug]         modified: Set()
[debug] Removed products: Set()
[debug] External API changes: API Changes: Set()
[debug] Modified binary dependencies: Set()
[debug] Initial directly invalidated sources: Set(/media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/main/java/com/FooBar/MainAc
tivity.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-gen/com/FooBar/R.java, /media/jdamon/Development/Docu
ments/Projects/learning_scala/Foo/target/android-gen/com/FooBar/BuildConfig.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo
/src/androidTest/java/com/FooBar/MainActivityTest.java)
[debug]
[debug] Sources indirectly invalidated by:
[debug]         product: Set()
[debug]         binary dep: Set()
[debug]         external source: Set()
[debug] All initially invalidated sources: Set(/media/jdamon/Development/Documents/Projects/learning_scala/Foo/src/main/java/com/FooBar/MainActiv
ity.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-gen/com/FooBar/R.java, /media/jdamon/Development/Documen
ts/Projects/learning_scala/Foo/target/android-gen/com/FooBar/BuildConfig.java, /media/jdamon/Development/Documents/Projects/learning_scala/Foo/sr
c/androidTest/java/com/FooBar/MainActivityTest.java)
[debug] Recompiling all 4 sources: invalidated sources (4) exceeded 50.0% of all sources
[info] Compiling 4 Java sources to /media/jdamon/Development/Documents/Projects/learning_scala/Foo/target/android-bin/classes...
[debug] Attempting to call javac directly...
[debug] com.sun.tools.javac.Main not found with appropriate method signature; forking javac instead
[debug] Forking javac: javac @/tmp/sbt_ebe6d072/argfile






WARNING - This e-mail or its attachments may contain controlled technical data or controlled technology within the definition of the International Traffic in Arms Regulations (ITAR) or Export Administration Regulations (EAR), and are subject to the export control laws of the U.S. Government. Transfer of this data or technology by any means to a foreign person, whether in the United States or abroad, without an export license or other approval from the U.S. Government, is prohibited. The information contained in this document is CONFIDENTIAL and property of ACCES I/O Products, Inc. Any unauthorized review, use, disclosure or distribution is prohibited without express written consent of ACCES I/O Products, Inc. If you are not the intended recipient, please contact the sender and destroy all copies of the original message and enclosed attachments.

Naftoli Gugenheim

unread,
Aug 13, 2015, 11:20:29 PM8/13/15
to simple-b...@googlegroups.com

I think the closest thing to what you want is "export."

> help export
export [--last] <task>+
Runs the specified tasks and prints the equivalent command lines or other exportable information for those runs.

--last
Uses information from the previous execution

NOTES: These command lines are necessarily approximate.  Usually tasks do not actually
execute the command line and the actual command line program may not be installed or
on the PATH.  Incremental tasks will typically show the command line for an
incremental run and not for a full run.  Many tasks have no direct command line
equivalent and will show nothing at all.


--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
To post to this group, send email to simple-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-build-tool.
For more options, visit https://groups.google.com/d/optout.

jda...@accesio.com

unread,
Aug 14, 2015, 12:53:40 PM8/14/15
to simple-build-tool
Many Many many Thanks,

That looks like it .

export --last compile

scalac -javabootclasspath ....
etc.

jda...@accesio.com

unread,
Aug 14, 2015, 1:23:23 PM8/14/15
to simple-build-tool
While this is very nice, how do you find out the subtasks that are completed for a compile ?

Specifically, I'm building a Scala Android app that needs to generate the TR.scala file and I need to find out what is breaking on that step.

Thanks for any ideas,

Josh Suereth

unread,
Aug 15, 2015, 9:22:03 AM8/15/15
to simple-b...@googlegroups.com
`inspect compile` should show you the subtasks it runs, `inspect tree compile` should show you more.   Additionally, starting sbt with `-Dsbt.task.timings=true` will print out a graph of how long each task takes for every task run, which could be useful.
Reply all
Reply to author
Forward
0 new messages