Skip to content

Latest commit

 

History

History
90 lines (68 loc) · 3.25 KB

README.md

File metadata and controls

90 lines (68 loc) · 3.25 KB

gradle-plugin-r

Build Status

A Gradle plugin for R projects.

This plugin helps create packages that are structured using devtools and usethis, documented using roxygen2, with dependencies managed using Renv (or optionally Packrat), and unit-tested using testthat.

J. Olson's R plugin inspired this one. One important difference is the use of Packrat, the other is, perhaps, a terser implementation.

Overview

The development workflows for R project are (gradle tasks):

R setup, build and packaging tasks
----------------------------------
document - Creates documentation for R package
installDeps - Installs common packaging dependencies
packageBuild - Builds an R package into a tarball
packageCheck - Runs checks for an R package
packageClean
packratClean - Removes packages (compiled and sources) managed by Packrat for an R package
packratRestore - Restores packages managed by Packrat for R package
renvClean - Removes packages (compiled and sources) managed by Renv for an R package
renvRestore - Restores packages managed by Renv for R package
restore - Restores all dependencies for a package.
setup - Sets up a skeleton R package (warning: non-idempotent task).
setupCreate - Ensures that pre-conditions for package setup are satisfied.
setupPackrat - Sets up a skeleton R package using Renv (warning: non-idempotent task).
setupRenv - Sets up a skeleton R package using Renv (warning: non-idempotent task)
test - Runs test for an R package

This project contains two directories:

  • plugin, which contain all the Groovy code, properties and build files
  • testRProject, a sample project with build file that uses this plugin

How To

  • Create a directory (this will be your R package)
  • Create a build.gradle file, which applies this plugin
buildscript {
  repositories {
      maven {
          url "https://plugins.gradle.org/m2/"
      }
  }
  dependencies {
      classpath "gradle.plugin.com.umayrh:gradle-plugin-r:0.3.1"
  }
}

apply plugin: "com.umayrh.rplugin"

It should also be possible to use Gradle's new plugin mechanism:

plugins {
    id "com.umayrh.rplugin" version "0.3.1"
}

Plugin Development Notes

If you add to or modify the code under plugin directory, then you can recompile, re-test, and re-package by running (inside plugin dir)

gradle build uploadArchives

To test the plugin itself, you can run gradle inside testRProject dir e.g.

gradle document

References