This plugin extracts the structure of an sbt build in XML format. It is used in Intellij Scala plugin in order to import arbitrary sbt projects into IDEA.
Please report any issues related to sbt-structure in IntelliJ on the IntelliJ Scala YouTrack project.
extractoris an sbt plugin that actually extracts information from the sbt build
coreis a shared library that is used by both
extractorand the Intellij Scala plugin.
Add to your
resolvers += Resolver.url("jb-bintray", url("https://dl.bintray.com/jetbrains/sbt-plugins"))(Resolver.ivyStylePatterns) libraryDependencies += "org.jetbrains" %% "sbt-structure-core" % "<version>"
Then run extractor or get XML of the structure any other way and deserialize it:
import org.jetbrains.sbt._ import org.jetbrains.sbt.XmlSerializer._ val structureXml: Elem = XML.load(...) val structure: Either[Throwable, StructureData] = structureXml.deserialize[StructureData]
Extractor can be run as a regular sbt plugin, or loaded into the build during an sbt shell session.
As an sbt plugin
The quickest way to try out the extractor is by adding it to your build in
project/plugins.sbt as an sbt plugin:
addSbtPlugin("org.jetbrains" % "sbt-structure-extractor" % "<version>")
Then from the sbt shell run:
This will output the xml directly to the shell.
To write the xml to a file, run:
set org.jetbrains.sbt.StructureKeys.sbtStructureOptions in Global := "prettyPrint download" */*:dumpStructureTo structure.xml
dumpStructure task uses the settings described below, the
dumpStructureTo task takes
sbtStructureFile as parameter instead.
This is the way Intellij-Scala imports projects by default.
Extractor is run in several steps:
- Configure it by defining
- Create necessary tasks by applying extractor's jar to your project
Here is an example of how to run extractor from sbt REPL:
set SettingKey[Option[File]]("sbtStructureOutputFile") in Global := Some(file("structure.xml")) set SettingKey[String]("sbtStructureOptions") in Global := "prettyPrint download" apply -cp <path-to-extractor-jar> org.jetbrains.sbt.CreateTasks */*:dumpStructure
sbt-structure-options contains space-separated list of options.
sbt-structure-output-file points to a file where structure will be written; if it is set to
None then structure will be dump into stdout.
Available options to set in
When this option is set extractor will run
updatecommand for each project in build and build complete repository of all transitive library dependencies
downloadoption to be set as well)
download+ downloading sources and javadocs for each transitive library dependency
This option tells extractor to download sources and javadocs for sbt itself and plugins.
This option will force extractor to prettify XML output. Useful for debug purposes.
- Testing against all supported sbt versions can be done with
- Testing against specific version of sbt, for example, 0.13.7:
^^ 0.13.7 test
- Selected tests can be run with
^ testOnly -- -ex "project name"
To publish artifacts bump version in
build.sbt and run in sbt REPL:
project extractor ^^ 0.12 publish ^^ 0.13 publish
Sbt 0.12 is built against Scala 2.9 and will not run on JVM 8. To test for 0.12, you need to run sbt with Java 7