forked from groovy/GMavenPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
294 additions
and
5 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
invoker.goals=clean test -e -ntp -Dmaven.plugin.validation=verbose | ||
#invoker.debug = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin-it-root</artifactId> | ||
<version>testing</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>gmavenplus-plugin-it-forkCompile</artifactId> | ||
<version>testing</version> | ||
<name>GMavenPlus Plugin Fork Compile Test</name> | ||
<description>The simplest compile with fork. | ||
</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>@groovyGroupId@</groupId> | ||
<artifactId>groovy</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.gmavenplus</groupId> | ||
<artifactId>gmavenplus-plugin</artifactId> | ||
<configuration> | ||
<parameters>true</parameters> | ||
<fork>true</fork> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
24 changes: 24 additions & 0 deletions
24
src/it/forkMode/src/main/groovy/org/codehaus/gmavenplus/SomeClass.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2011 the original author or authors. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package org.codehaus.gmavenplus | ||
|
||
|
||
class SomeClass { | ||
|
||
void someMethod(String param1, String param2) {} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
src/it/forkMode/src/test/java/org/codehaus/gmavenplus/SomeClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2011 the original author or authors. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
package org.codehaus.gmavenplus; | ||
|
||
import groovy.lang.GroovySystem; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Parameter; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
|
||
public class SomeClassTest { | ||
|
||
@Test | ||
public void testSomeMethod() throws NoSuchMethodException { | ||
Method method = SomeClass.class.getDeclaredMethod("someMethod", String.class, String.class); | ||
List<Parameter> parameterNames = Arrays.asList(method.getParameters()); | ||
|
||
Assert.assertEquals(2, parameterNames.size()); | ||
|
||
if (GroovySystem.getVersion().startsWith("1.5") | ||
|| GroovySystem.getVersion().startsWith("1.6") | ||
|| GroovySystem.getVersion().startsWith("1.7") | ||
|| GroovySystem.getVersion().startsWith("1.8") | ||
|| GroovySystem.getVersion().startsWith("1.9") | ||
|| GroovySystem.getVersion().startsWith("2.0") | ||
|| GroovySystem.getVersion().startsWith("2.1") | ||
|| GroovySystem.getVersion().startsWith("2.2") | ||
|| GroovySystem.getVersion().startsWith("2.3") | ||
|| GroovySystem.getVersion().startsWith("2.4")) { | ||
Assert.assertEquals("arg0", parameterNames.get(0).getName()); | ||
Assert.assertEquals("arg1", parameterNames.get(1).getName()); | ||
} else { | ||
Assert.assertEquals("param1", parameterNames.get(0).getName()); | ||
Assert.assertEquals("param2", parameterNames.get(1).getName()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/org/codehaus/gmavenplus/mojo/GroovycLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.codehaus.gmavenplus.mojo; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import org.apache.maven.plugin.logging.Log; | ||
|
||
public class GroovycLogger implements Runnable { | ||
|
||
private final InputStream inputStream; | ||
private final Log log; | ||
private final LogTarget level; | ||
|
||
public GroovycLogger(InputStream inputStream, Log log, LogTarget level) { | ||
this.inputStream = inputStream; | ||
this.log = log; | ||
this.level = level; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(this.inputStream))) { | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
System.out.println(line); | ||
if (this.level == LogTarget.ERROR) { | ||
this.log.error(line); | ||
|
||
} else { | ||
this.log.info(line); | ||
} | ||
} | ||
} catch (IOException ioException) { | ||
this.log.error(ioException); | ||
} | ||
} | ||
|
||
public enum LogTarget { | ||
INFO, | ||
ERROR; | ||
} | ||
} |