GithubHelp home page GithubHelp logo

bhanditz / sbt-structure Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jetbrains/sbt-structure

0.0 2.0 0.0 27.09 MB

SBT plugin to collect information about project structure

License: Other

Scala 100.00%

sbt-structure's Introduction

official JetBrains project

Download Build Status

Gitter

sbt-structure

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.

Problems?

Please report any issues related to sbt-structure in IntelliJ on the IntelliJ Scala YouTrack project.

Project structure

  • extractor is an sbt plugin that actually extracts information from the sbt build
  • core is a shared library that is used by both extractor and the Intellij Scala plugin.

Usage

Core

Add to your build.sbt

resolvers += Resolver.url("jb-bintray", url("http://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

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:

*/*:dumpStructure

This will output the xml directly to the shell.

To write the xml to a file, run:

set org.jetbrains.sbt.StrcutureKeys.sbtStructureOptions in Global := "prettyPrint download"
*/*:dumpStructureTo structure.xml

The dumpStructure task uses the settings described below, the dumpStructureTo task takes sbtStructureFile as parameter instead.

Sideloading

This is the way Intellij-Scala imports projects by default.

Extractor is run in several steps:

  • Configure it by defining sbt-structure-output-file and sbt-structure-options settings in Global scope.
  • Create necessary tasks by applying extractor's jar to your project
  • Run dumpStructure task in Global scope

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

Settings

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 sbt-structure-options:

  • download

    When this option is set extractor will run update command for each project in build and build complete repository of all transitive library dependencies

  • resolveClassifiers (requires download option to be set as well)

    Same as download + downloading sources and javadocs for each transitive library dependency

  • resolveSbtClassifiers

    This option tells extractor to download sources and javadocs for sbt itself and plugins.

  • prettyPrint

    This option will force extractor to prettify XML output. Useful for debug purposes.

Development notes

  • Testing against all supported sbt versions can be done with ^ test command
  • Testing against specific version of sbt, for example, 0.13.7: ^^ 0.13.7 test
  • Selected tests can be run with testOnly command, e.g. ^ 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

Compatibility

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

sbt-structure's People

Contributors

pavelfatin avatar jastice avatar mutcianm avatar alefas avatar pfn avatar hekaldama avatar azolotko avatar alexarchambault avatar gitter-badger avatar niktrop avatar seroperson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.