Skip to content

Commit

Permalink
Adds initial version of the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Jul 20, 2012
0 parents commit 34a2a27
Show file tree
Hide file tree
Showing 8 changed files with 15,931 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .gitignore
@@ -0,0 +1,65 @@
## generic files to ignore
*~
*.lock
*.DS_Store
*.swp
*.out

# rails specific
*.sqlite3
config/database.yml
log/*
tmp/*

# java specific
*.class

# python specific
*.pyc

# xcode/iphone specific
build/*
*.pbxuser
*.mode2v3
*.mode1v3
*.perspective
*.perspectivev3
*~.nib

# akka specific
logs/*

# sbt specific
project/boot
lib_managed/*
project/build/target
project/build/lib_managed
project/build/src_managed
project/plugins/lib_managed
project/plugins/target
project/plugins/src_managed
project/plugins/project

core/lib_managed
core/target
pubsub/lib_managed
pubsub/target

# eclipse specific
.metadata
jrebel.lic
.idea/workspace.xml
.idea/bashsupport_project.xml

*.iml
*.ipr
*.iws

target
.idea
.settings
.classpath
.project
.ensime*
*.sublime-*
.cache
16 changes: 16 additions & 0 deletions LICENSE
@@ -0,0 +1,16 @@
The MIT License (MIT)
Copyright (c) 2011 Scalatra.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77 changes: 77 additions & 0 deletions README.md
@@ -0,0 +1,77 @@
## SBT require.js

A plugin to run r.js from sbt which hooks into the compile task.

At this stage the plugin shells out to node.js so it does require node.js to be installed on the machine compiling the application.

[Installing Node.js](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager)

Adding the plugin:

```scala
addSbtPlugin("org.scalatra.requirejs" % "sbt-requirejs" % "0.0.1")
```

Using the plugin:

*build.sbt*

```scala
import RequireJsKeys._

seq(requireJsSettings: _*)

buildProfile in (Compile, requireJs) := (
("uglify" -> ("ascii_only" -> true)) ~
("pragmasOnSave" -> ("excludeCoffeeScript" -> true) ~ ("excludeJade" -> true)) ~
("paths" -> ("jquery" -> "empty:")) ~
("stubModules" -> List("cs", "jade")) ~
("modules" -> List[JValue](("name" -> "main") ~ ("exclude" -> List("coffee-script", "jade"))))
)

baseUrl in (Compile, requireJs) := "js"

mainConfigFile in (Compile, requireJs) <<=
(sourceDirectory in (Compile, requireJs), baseUrl in (Compile, requireJs))((a, b) => Some(a / b / "main.js"))
```

*Defaults*

```scala
// The location to put the compiled requirejs application
webApp in requireJs <<= (sourceDirectory in c)(_ / "webapp")

// The location of the source files for the require.js app
sourceDirectory in requireJs <<= (sourceDirectory in c)(_ / "requirejs")

// The location of the r.js file
rjs in requireJs <<= (target in c)(_ / "r.js")

// The location of the node.js binary
nodeBin in requireJs := ("which node" !!).trim

// A JSON file to use as source for the require js build profile
buildProfileFile in requireJs <<= (baseDirectory in c)(_ / "project" / "requirejs.build.json")

// A lift-json JValue object to use as r.js build profile (overrides settings defined in buildProfileFile)
buildProfile in requireJs := JNothing

// The generated profile file for r.js to actually use when running the optimizer
buildProfileGenerated in requireJs <<= (target in c)(_ / "requirejs.build.js")

// The working directory for the optimizer to do its work.
target in requireJs <<= (target in c)(_ / "requirejs")

// The baseUrl to use in the build profile
baseUrl in requireJs := "scripts"

// The main config file to use with the path definitions (this comes from your app)
mainConfigFile in requireJs := None

// files to include when copying from the optimization step to the webapp
includeFilter in requireJs := "*"

// files to exclude when copying from the optimization step to the webapp
excludeFilter in requireJs := "build.txt" || (".*" - ".") || "_*" || HiddenFileFilter
```

67 changes: 67 additions & 0 deletions build.sbt
@@ -0,0 +1,67 @@
import xml.Group

sbtPlugin := true

name := "sbt-requirejs"

organization := "org.scalatra.requirejs"

version := "0.0.1-SNAPSHOT"

libraryDependencies ++= Seq(
"net.liftweb" %% "lift-json" % "2.4"
)

publishMavenStyle := true

publishTo <<= version { (v: String) =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

publishArtifact in Test := false

pomIncludeRepository := { x => false }

packageOptions <<= (packageOptions, name, version, organization) map {
(opts, title, version, vendor) =>
opts :+ Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> System.getProperty("user.name"),
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> title,
"Specification-Vendor" -> "Scalatra",
"Specification-Version" -> version,
"Implementation-Title" -> title,
"Implementation-Version" -> version,
"Implementation-Vendor-Id" -> vendor,
"Implementation-Vendor" -> "Scalatra",
"Implementation-Url" -> "https://github.com/scalatra/sbt-requirejs"
)
}

homepage := Some(url("https://github.com/scalatra/sbt-requirejs"))

startYear := Some(2012)

licenses := Seq(("MIT", url("http://github.com/scalatra/sbt-requirejs/raw/HEAD/LICENSE")))

pomExtra <<= (pomExtra, name, description) {(pom, name, desc) => pom ++ Group(
<scm>
<connection>scm:git:git://github.com/scalatra/sbt-requirejs.git</connection>
<developerConnection>scm:git:git@github.com:scalatra/sbt-requirejs.git</developerConnection>
<url>https://github.com/scalatra/sbt-requirejs</url>
</scm>
<developers>
<developer>
<id>casualjim</id>
<name>Ivan Porto Carrero</name>
<url>http://flanders.co.nz/</url>
</developer>
</developers>
)}


1 change: 1 addition & 0 deletions project/build.properties
@@ -0,0 +1 @@
sbt.version=0.11.3
5 changes: 5 additions & 0 deletions project/plugins.sbt
@@ -0,0 +1,5 @@
resolvers += Resolver.url("sbt-plugin-releases",
new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(
Resolver.ivyStylePatterns)

addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")

0 comments on commit 34a2a27

Please sign in to comment.