Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Plugins for Gradle

tree: 41a4fb6de3

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 sample
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 build.gradle
README.md

Gradle Plugins

These are a variety of plugins that I wrote for Gradle and figured I'd share with the world.

All of the plugins below have the class name com.smokejumperit.gradle.NameOfPlugin. So AllPlugins is com.smokejumperit.gradle.AllPlugins, and EnvPlugin is com.smokejumperit.gradle.EnvPlugin. And so on.

AllPlugins

Description

Convenience plugin that loads all the plugins listed below.

ClassLoadersPlugin

Description

Provides two methods on the project object to work with configuration classloaders:

  • classLoaderFor(String... configNames)—Provides a java.lang.ClassLoader consisting of all of the dependencies in the named configurations, in the order specified.

  • classFor(String className, String... configNames)—Looks up the class for name className using the class loader for configs in configNames.

Note that each call to one of these methods generates a new ClassLoader instance: this is a feature, not a bug, because it allows the ClassLoader to be garbage collected if it and its classes are done being consumed. This can be critical to saving PermGen space.

Example

task(foo) << {
  project.classFor("my.app.Main", bar).main()
}

ExecPlugin

Description

Provides methods exec(cmd) and exec(cmd, baseDir) on the project to execute shell commands. If the command does not return 0, the build will fail.

Example

project.exec("ls -al", project.buildDir)

EnvPlugin

Description

Provides a map property on the project named env consisting of the external system's environment variables. Also provides a method env(key) on the project that will return a particular environment variable's value, and explode if it does not exist.

ProjectExtPlugin

Description

This is a holder for various extensions to the Project API.

Example

// Attempt to make path relative to project if it is a subdir
project.tryRelativePath("/some/random/path/foo/bar/baz")

RunJRubyPlugin

Description

A plugin to run JRuby scripts and manage gems.

API

project.gemHome // Provides the location for where gems are installed
project.gemHome(String gemName) // Provides the root folder of the gem
project.gemScript(String gemName) // Provides the main script for the gem
project.runJRuby(String cmdArg, String[] configs=['runJRuby'])
project.useGem(String gemName) // Installs a gem (if not currently installed)

CukePlugin

Description

Runs Cucumber. Specifically, provides a task (runFeatures) that executes the features, which are assumed to reside in ./src/test/features/. By default, the classloader for the cuke configuration is used when the features are executed. That configuration includes testRuntime, runtime, jruby, and the classes generated from the test and main source sets.

To modify the defaults, change convention.plugin.cuke. The configs property of that object is a list of configurations to load when executing feature tests. The featuresDir property of that object denotes where the root of the features reside.

Installation

Add the following lines to your build script to add the jars to your buildscript classpath and use the plugins:

// Example of using two plugins
usePlugin(com.smokejumperit.gradle.ClassLoadersPlugin)
usePlugin(com.smokejumperit.gradle.ExecPlugin)

buildscript {
  repositories {
    mavenRepo urls:'http://repo.smokejumperit.com'
  }
  dependencies {
    classpath 'com.smokejumperit:gradle-plugins:0.5'
  }
}

If you want to ust use all the SmokejumperIT plugins, you can do this:

usePlugin(com.smokejumperit.gradle.AllPlugins)

buildscript {
  repositories {
    mavenRepo urls:'http://repo.smokejumperit.com'
  }
  dependencies {
    classpath 'com.smokejumperit:gradle-plugins:0.5'
  }
}

See the sample directory of this project for a build script which does this.

Author and Origin

These plugins were written by Robert Fischer. They are published at GitHub:RobertFischer/gradle-plugins.

License

All these plugins are licensed under the Creative Commons — CC0 1.0 Universal license with no warranty (expressed or implied) for any purpose.

Something went wrong with that request. Please try again.