Git Product home page Git Product logo

np's Introduction

np

Simple utility for creating new projects in Sbt

Steps it took to get this project started

$ touch build.sbt
$ mkdir -p src/{main,test}/scala
$ e build.sbt # fill in the basics (name, organization, version)
$ touch README.md && e README.md
$ sbt
# start coding

Desired steps to take to start this project

$ sbt
$ np name:np
# start coding

^ No context switching ^.

Already have a project and want a sub project? No problem.

$ sbt
$ np name:my-sub-project dir:sub-project-dir

This will create a new sbt project source tree for a project named my-sub-project under the directory named sub-project-dir relative you your projects base directory. From your main build configuration you can use this as a stub and reference it as.

lazy val sub = Project("my-sub-project", file("sub-project-dir"))

Or remove the generated stub build.sbt and just use the generate source tree

Requirements

  • Simple Build Tool
  • The burning desire to start your projects quickly

Installation

In most cases a global installation will make the most sense as the target usage for this plugin is the creation of new projects

For sbt 0.12 or lower

For global installation, if you have a ~/.sbt directory created, in a ~/.sbt/plugins/build.sbt file add the following

For local installation, if you have a ~/project directory created, in a ~/project/build.sbt file add the following

addSbtPlugin("me.lessis" % "np" % "0.2.0")

resolvers += Resolver.url("sbt-plugin-releases",
  url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(
    Resolver.ivyStylePatterns)

Or if you prefer, you can call depend on the project reference as a git repository.

import sbt._

object Plugins extends Build {
  lazy val root = Project("root", file(".")) dependsOn(
    uri("git://github.com/softprops/np.git#0.2.0")
  )
}

Be sure to explicitly mix np's settings into your build definition.

seq(npSettings: _*)

Doing this in a global .sbt file under ~/.sbt (e.g. ~/.sbt/np.sbt) will make np's setting available to all of your sbt projects.

For sbt 0.13+

If you don't already have one, create an ~/.sbt/0.13/plugins directory. And inside of it, create an np.sbt ( it doesn't matter what you call it ) file containing the line

addSbtPlugin("me.lessis" % "np" % "0.2.0")

This will make npSettings globally visible to your project definitions.

If you wish to globally mix in npSettings, create a file under ~/.sbt/0.13 called np.sbt ( it doesn't matter what you call this either ) containing the line

seq(npSettings: _*)

Customization

If you have a lot of projects that use the same ivy organization id (your own) or you always start projects with the same version conventions (a SNAPSHOT), you may want to define your own custom global overrides.

To do so, in a ~/.sbt/np.sbt file in sbt 0.12, or ~/.sbt/0.13/np.sbt file in 0.13, add the following.

seq(npSettings:_*)

(NpKeys.defaults in (Compile, NpKeys.np)) ~= {
  _.copy(org="me.lessis", version="0.1.0-SNAPSHOT")
}

See the np option reference section below for all available options

Settings

np               # generates a new project given a set of options
scout(for np)    # detects potential conflicts with generating a project, recommended before np
usage(for np)    # displays usage options
defaults(for np) # default values for options

In sbt 0.13 you can resolve the scoped settings using ::

np::scout
np::usage
np::defaults

np option reference

np generates sbt projects given key:value options. Below is a list of current options

org     Project organization. Defaults to defaults key sbt built-in default
name    Project name. Defaults to defaults key or sbt built-in default
version Project version. Defaults to defaults key or sbt built-in default
plugin  Boolean indicator of whether the project is a plugin project. Defaults to defaults key or false
dir     Path to dir where np should generate project. Defaults to defaults key or '.'

Contributing / Issues

Please post any issues or ideas you have to np's issues

If you like rolling up your sleeves, feel free to fork and create a feature branch

Doug Tangren (softprops) 2011-12

np's People

Contributors

aishfenton avatar blaisorblade avatar btakashi avatar danluu avatar softprops avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

np's Issues

Generate directories even if a build.sbt file exists

For me, the most useful aspect of 'np' is the generation of src/main/scala, resources, test etc, because I use Intellij and have to do it manually otherwise. I'd like to be able to use the np command to do this, even if I have defined my build.sbt file manually. However, currently this seems disallowed:

> np
[trace] Stack trace suppressed: run last compile:np for the full output.
[error] (compile:np)
[error] existing project detected at the path /Users/ben_hutchison/swork/scala101
[error] Total time: 0 s, completed Feb 13, 2014 12:18:43 PM

Create default .gitignore

How about having np create a default .gitignore when creating a new SBT project? Here is what I usually put in .gitignore:

.cache
/server.conf
/project/boot
/project/project
/project/target
/target
/.idea
/.idea_modules
/lib
*~

Cannot install

I followed the instructions, i.e added:

resolvers += "lessis" at "http://repo.lessis.me"

addSbtPlugin("me.lessis" % "np" % "0.2.0")

seq(npSettings: _*)

to

~/.sbt/plugins/build.sbt

but when running sbt, I get the following error:

/home/gmosx/.sbt/plugins/build.sbt:5: error: not found: value npSettings
seq(npSettings: _*)
^
[error] Type error in expression

Any ideas?

copy in settings from a template

I would find this more useful if I could point it at a file with settings to be copied into all new projects. (I am super averse to global settings since until I partitioned sbt versions from one another they always broke, and even with that out of the way they create project fragility.)

npSettings "mix-in" seems to be required in SBT 0.13

The docs suggest you /may/, as opposed to /must/, mixin npSettings at the global ~/.sbt/build.sbt level, and suggests that if you do not, the settings are visible under a npSettings namespace.

In SBT 0.13, when I omit 'seq(npSettings: _*)' from the global config, I'm not able to access npSettings nor np in a project - see below. Please show an example of use in the docs, or else make it clearer it's mandatory.

[ben_hutchison@VIC009228M scala101 ]$ cat ~/.sbt/0.13/build.sbt

//IDEs download source code but not javadoc for dependencies
EclipseKeys.withSource := true

transitiveClassifiers in Global := Seq(Artifact.SourceClassifier)

[ben_hutchison@VIC009228M scala101 ]$ cat ~/.sbt/0.13/plugins/build.sbt

//sync SBT project definition to IDEs
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

//quickly init new scala projects
addSbtPlugin("me.lessis" % "np" % "0.2.0")
[ben_hutchison@VIC009228M test ]$ sbt
[info] Loading global plugins from /Users/ben_hutchison/.sbt/0.13/plugins
[info] Set current project to test (in build file:/Users/ben_hutchison/swork/test/)
> npSettings
[error] Not a valid command: npSettings (similar: settings)
[error] Not a valid project ID: npSettings
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: npSettings (similar: settingsData, moduleSettings, settings-data)
[error] npSettings
[error]           ^
> np
[error] Not a valid command: np
[error] Not a valid project ID: np
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: np
[error] np
[error]   ^

Command not defined

I installed the plugin as specified in the README:

addSbtPlugin("me.lessis" % "np" % "0.2.0")

resolvers += "lessis" at "http://repo.lessis.me"

I then created a new folder, cd'ed into it, ran sbt, and then attempted to run np:

> np
[error] Not a valid command: np (similar: <, -, inspect)
[error] Not a valid project ID: np
[error] Not a valid configuration: np
[error] Not a valid key: np (similar: run, name, skip)
[error] np
[error]   ^

Did I do something wrong? This is using sbt 0.11.1.

dir key create an unnecessary target folder

If dir specified, np will create a target folder along with project folder.

And I think if the dir key is not specified, np should create a directory using project name by default.

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.