All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.bancaditalia.oss.RValidate Maven / Gradle / Ivy

Go to download

This plugin brings into Maven the lifecycle of an R package. It builds onto the existing R installation to perform build, check, etc. It provides means to complete a DESCRIPTION file with version, etc. In the future, It will allow to deploy the project to CRAN as well as a Maven artifact repository.

The newest version!
package it.bancaditalia.oss;

import java.io.File;
import java.util.Vector;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.rosuda.JRI.REXP;
import org.rosuda.JRI.Rengine;

/**
 * 

* Goal that performs some initial checks on the package metadata. *

* *

* Compliance requires passing tests enumerated in * official documentation *

*/ @Mojo(name = "validate", defaultPhase = LifecyclePhase.PREPARE_PACKAGE) public class RValidate extends AbstractRMojo { /** * You can skip the execution of the plugin if you need to. Its use is NOT RECOMMENDED, but quite convenient on * occasion. */ @Parameter(property = "R.validate.skip", defaultValue = "false") private boolean skip; @SuppressWarnings("unchecked") @Override public void execute() throws MojoExecutionException { Log log = getLog(); if (isSkip()) { getLog().info("Skipping the execution."); return; } File description = new File(project.getBuild().getOutputDirectory() + File.separator + "DESCRIPTION"); if (!description.exists()) { log.error("DESCRIPTION file does not exists."); log.error("Remember to use the 'sources' goal."); throw new MojoExecutionException("DESCRIPTION file does not exists."); } Rengine engine = getEngine(); synchronized (engine) { String statement = "tools:::.check_package_description('" + description.toString().replaceAll("\\\\", "\\\\") + "')"; log.debug("Executing R statement: " + statement); REXP result = tryCatch(statement); for (REXP elem : (Vector) result.asVector()) log.error(elem.asString()); if (result.asVector().size() > 0) throw new MojoExecutionException("Project metadata contains errors."); } log.info("Validation complete."); } /** * @return {@link #skip} */ public boolean isSkip() { return skip; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy