You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/09 15:30:00 UTC

[maven-scripting-plugin] branch master created (now e81cfb0)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git.


      at e81cfb0  o Reverted last commit to reset to release version parent's.

This branch includes the following new commits:

     new e411e95  Initial commit maven-scipting-plugin, a jsr223 wrapping maven plugin.
     new adecb82  o Updated to latest parent SNAPSHOT.
     new e81cfb0  o Reverted last commit to reset to release version parent's.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].

[maven-scripting-plugin] 03/03: o Reverted last commit to reset to release version parent's.

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git

commit e81cfb097d4654bf20f0220fb246c34036441aff
Author: Christian Schulte <sc...@apache.org>
AuthorDate: Sun Dec 18 03:37:05 2016 +0000

    o Reverted last commit to reset to release version parent's.
    
    
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1774844 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 936a0ca..2af17e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>31-SNAPSHOT</version>
+    <version>30</version>
     <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
   </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.

[maven-scripting-plugin] 02/03: o Updated to latest parent SNAPSHOT.

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git

commit adecb82a78a5899b9162b55d8eb6b4a3943af209
Author: Christian Schulte <sc...@apache.org>
AuthorDate: Sun Dec 18 00:49:25 2016 +0000

    o Updated to latest parent SNAPSHOT.
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1774838 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 2af17e3..936a0ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>30</version>
+    <version>31-SNAPSHOT</version>
     <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
   </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.

[maven-scripting-plugin] 01/03: Initial commit maven-scipting-plugin, a jsr223 wrapping maven plugin.

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-scripting-plugin.git

commit e411e95dd47e4235b415fdf550535d97023607d2
Author: Robert Scholte <rf...@apache.org>
AuthorDate: Sun Nov 20 13:08:33 2016 +0000

    Initial commit maven-scipting-plugin, a jsr223 wrapping maven plugin.
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1770555 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 144 +++++++++++++++++++++
 src/it/groovy-script/pom.xml                       |  47 +++++++
 src/it/settings.xml                                |  55 ++++++++
 .../apache/maven/plugins/scripting/EvalMojo.java   | 109 ++++++++++++++++
 4 files changed, 355 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2af17e3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,144 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.plugins</groupId>
+    <artifactId>maven-plugins</artifactId>
+    <version>30</version>
+    <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
+  </parent>
+
+  <artifactId>maven-scripting-plugin</artifactId>
+  <version>3.0.0-SNAPSHOT</version>
+  <packaging>maven-plugin</packaging>
+
+  <name>Apache Maven Scripting Plugin</name>
+  <description>
+    The Maven Scripting Plugin is a plugin that wrapped the Scripting API accoring to JSR223
+  </description>
+  <inceptionYear>2016</inceptionYear>
+
+  <prerequisites>
+    <maven>${mavenVersion}</maven>
+  </prerequisites>
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-scripting-plugin</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-scripting-plugin</developerConnection>
+    <url>http://svn.apache.org/viewvc/maven/plugins/trunk/maven-scripting-plugin</url>
+  </scm>
+  <issueManagement>
+    <system>JIRA</system>
+    <url>https://issues.apache.org/jira/browse/MSCRIPTING</url>
+  </issueManagement>
+  <distributionManagement>
+    <site>
+      <id>apache.website</id>
+      <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</url>
+    </site>
+  </distributionManagement>
+
+  <properties>
+    <mavenVersion>3.0</mavenVersion>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>${mavenVersion}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-shared-utils</artifactId>
+      <version>3.1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-core</artifactId>
+      <version>${mavenVersion}</version>
+    </dependency>
+
+    <!-- dependencies to annotations -->
+    <dependency>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <!-- ScriptEngines -->
+    <dependency>
+      <groupId>org.codehaus.groovy</groupId>
+      <artifactId>groovy-jsr223</artifactId>
+      <version>2.4.7</version>
+    </dependency>
+
+    <!-- Test -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin-testing</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>2.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-compat</artifactId>
+      <version>${mavenVersion}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>run-its</id>
+      <build>
+        <pluginManagement>
+          <plugins>
+            <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-invoker-plugin</artifactId>
+              <configuration>
+                <projectsDirectory>src/it</projectsDirectory>
+                <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+                <preBuildHookScript>setup</preBuildHookScript>
+                <postBuildHookScript>verify</postBuildHookScript>
+                <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+                <settingsFile>src/it/settings.xml</settingsFile>
+                <goals>
+                  <goal>scripting:eval</goal>
+                </goals>
+              </configuration>
+            </plugin>
+          </plugins>
+        </pluginManagement>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/src/it/groovy-script/pom.xml b/src/it/groovy-script/pom.xml
new file mode 100644
index 0000000..5098a79
--- /dev/null
+++ b/src/it/groovy-script/pom.xml
@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.scripting.its</groupId>
+  <artifactId>groovy-script</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-scripting-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <engineName>groovy</engineName>
+          <script>
+          <![CDATA[
+            (1..10).sum() + ' ' + project.artifactId
+          ]]>
+          </script>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..35dbcec
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+  <profiles>
+    <profile>
+      <id>it-repo</id>
+      <repositories>
+        <repository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </repository>
+      </repositories>
+      <pluginRepositories>
+        <pluginRepository>
+          <id>local.central</id>
+          <url>@localRepositoryUrl@</url>
+          <releases>
+            <enabled>true</enabled>
+          </releases>
+          <snapshots>
+            <enabled>true</enabled>
+          </snapshots>
+        </pluginRepository>
+      </pluginRepositories>
+    </profile>
+  </profiles>
+  <activeProfiles>
+    <activeProfile>it-repo</activeProfile>
+  </activeProfiles>
+</settings>
diff --git a/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java
new file mode 100644
index 0000000..f4c349a
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugins/scripting/EvalMojo.java
@@ -0,0 +1,109 @@
+package org.apache.maven.plugins.scripting;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+import javax.script.ScriptException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Evaluate the specified script
+ * 
+ * @author Robert Scholte
+ * @since 3.0.0
+ */
+@Mojo( name = "eval" )
+public class EvalMojo
+    extends AbstractMojo
+{
+    @Parameter( required = true )
+    private String engineName; // or map extension to engineName??
+
+    /**
+     * When used, also specify the engineName
+     */
+    @Parameter
+    private String script;
+
+    // script variables
+    @Parameter( defaultValue = "${project}", readonly = true )
+    private MavenProject project;
+    
+    private ScriptEngineManager manager = new ScriptEngineManager();
+
+    @Override
+    public void execute()
+        throws MojoExecutionException, MojoFailureException
+    {
+        ScriptEngine engine = null;
+        
+        if ( script != null )
+        {
+            engine = getScriptEngine( engineName );
+
+            if ( engine == null )
+            {
+                throw new MojoFailureException( "Missing scriptEngine" );
+            }
+        }
+        else
+        {
+            // from file
+        }
+
+        try
+        {
+            ScriptContext context = engine.getContext();
+            context.setAttribute( "project", project, ScriptContext.GLOBAL_SCOPE );
+            
+            Object result = engine.eval( script );
+            
+            getLog().info( "Result:" );
+            if ( result != null )
+            {
+                getLog().info( result.toString() );
+            }
+        }
+        catch ( ScriptException e )
+        {
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+    }
+    
+    private ScriptEngine getScriptEngine( String name )
+    {
+        if ( name == null ) 
+        {
+            return null;
+        }
+        else
+        {
+            return manager.getEngineByName( engineName );
+        }
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.