Re: How to start building an SBT plugin?

165 views
Skip to first unread message

eugene yokota

unread,
Jan 16, 2013, 11:27:56 PM1/16/13
to simple-b...@googlegroups.com
The best place to start would be to understand sbt 0.12 well by reading 

- [Getting Started Guide](http://www.scala-sbt.org/release/docs/Getting-Started/index.html)

My unofficial document would also help since I went through similar process of trying to port 0.7 plugins:

- [an unofficial guide to sbt 0.10 v2.0](http://eed3si9n.com/sbt-010-guide)

Finally, you should take a look at existing plugin's source and compare 0.7 version and 0.12 version:
- [softprops/assembly-sbt](https://github.com/softprops/assembly-sbt)

-eugene

On Wednesday, January 16, 2013 3:25:25 PM UTC-5, ilango g wrote:
I am trying to understand where to start. What might be the first place to start when writing a plugin for SBT 0.12.1 and Scala 2.9/2.10.
In this case, which Scala source file in the SBT source codebase can I tap into to start writing this.
Any recommendations, suggestions or pointers are appreciated. My thanks to everyone for their time. Meanwhile I will do my research and try to come up with a starting point.

 

ilango g

unread,
Jan 17, 2013, 10:04:03 AM1/17/13
to simple-b...@googlegroups.com
Thanks, Eugene. I am reading your unofficial guide right now. 

On Wednesday, January 16, 2013 2:25:25 PM UTC-6, ilango g wrote:
I am asking this question because I ran into a problem with a certain plugin (that I call a LibPlugin) that I thought would help me resolve library dependencies better. The reason for using this plugin was to speed up development time. I tried to incorporate this plugin into my project and ran into difficulties. I realized that plugin was written more than 2 years ago for SBT 0.7 and Scala 2.8/2.9. If I were to use the functionality that this plugin provides I would need it to work for Scala 2.10 and SBT 0.10 or above.  I compared the code of SBT 0.7 and 0.10 and above and found that the code was quite different. 
Let me come to the point. The code for the plugin is in a source file called LibraryPlugin.scala. Inside this file is a trait called ResolverPlugin that extends Project like this:
 
trait ResolverPlugin extends Project

I was curious to find out more about Project. So, off I went and referenced the source code for SBT-0.7 here: https://github.com/harrah/xsbt/tree/0.7/sbt/src/main/scala/sbt
Inside Project.scala lies trait Project, which our trait ResolverPlugin extends. The trait is defined thus:

trait Project extends TaskManager with Dag[Project] with BasicEnvironment {
----
}

-----------------------------------------------------------------------------------------------
Curious about SBT-0.12.1, I reference the source code here: https://github.com/harrah/xsbt/tree/0.12.1/main
I located Project.scala hoping to find the equivalent Project trait. Indeed, there is a Project trait but it appears as a sealed trait like this:

sealed trait ProjectDefinition[PR <: ProjectReference]{
------
}
----------------------

Now this is the only Scala source file that the LibPlugin uses.
Reply all
Reply to author
Forward
0 new messages