Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#282] fork parameter #283

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,16 @@ jobs:
with:
distribution: temurin
java-version: 17
- name: install groovy
shell: bash
run: >
curl -s "https://get.sdkman.io" | bash;
source "$HOME/.sdkman/bin/sdkman-init.sh";
sdk install groovy ${{ matrix.groovy-version }}
- name: full test
shell: bash
run: >-
source "$HOME/.sdkman/bin/sdkman-init.sh";
sdk use groovy ${{ matrix.groovy-version }};
./mvnw ${MAVEN_ARGS} ${MVN_GROOVY_GROUP_ID} ${MVN_GROOVY_VERSION}
clean install invoker:install invoker:run
2 changes: 2 additions & 0 deletions src/it/forkMode/invoker.properties
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
59 changes: 59 additions & 0 deletions src/it/forkMode/pom.xml
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>
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) {}

}
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());
}
}

}
Loading