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

com.carrotgarden.maven.aws.grv.GroovyExec Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
/**
 * Copyright (C) 2010-2012 Andrei Pozolotin 
 *
 * All rights reserved. Licensed under the OSI BSD License.
 *
 * http://www.opensource.org/licenses/bsd-license.php
 */
package com.carrotgarden.maven.aws.grv;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;

/**
 * groovy script executor; has access to {@link MavenProject};
 * 

* for example: * *

 * def value = project.properties['key'] // read from project
 * project.properties['key'] = value + 1 // save into project
 * 
* * @goal groovy-execute-script * * @phase prepare-package * * @inheritByDefault true * * @requiresDependencyResolution test * */ public class GroovyExec extends GroovyBase { private String singleLine(String text) { text = text.replaceAll("\n", ";"); text = text.replaceAll("\\s+", " "); return text; } @Override public void execute() throws MojoExecutionException, MojoFailureException { try { getLog().info("groovy exec init "); final CarrotGroovyRunner runner = newRunner(); if (groovyFile != null && groovyFile.exists()) { getLog().info("groovy exec file : " + groovyFile); runner.execute(groovyFile); } if (groovyText != null && groovyText.length() != 0) { getLog().info("groovy exec text : " + singleLine(groovyText)); runner.execute(groovyText); } getLog().info("groovy exec done "); } catch (final Exception e) { throw new MojoFailureException("bada-boom", e); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy