Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2034 from daspilker/2.0-JENKINS-21249
[JENKINS-21249] Update Groovy to 2.4.6
  • Loading branch information
kohsuke committed Mar 11, 2016
2 parents 219481a + 2370795 commit 54d1cf1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
6 changes: 3 additions & 3 deletions core/pom.xml
Expand Up @@ -41,7 +41,7 @@ THE SOFTWARE.
<staplerFork>true</staplerFork>
<stapler.version>1.240</stapler.version>
<spring.version>2.5.6.SEC03</spring.version>
<groovy.version>1.8.9</groovy.version>
<groovy.version>2.4.6</groovy.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -411,13 +411,13 @@ THE SOFTWARE.
<dependency><!-- groovy shell uses this but uses an optional dependency -->
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>1.0</version>
<version>2.12</version>
<scope>compile</scope>
</dependency>
<dependency><!-- groovy shell uses this but it doesn't declare this dependency -->
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.9</version>
<version>1.11</version>
</dependency>
<dependency>
<!--
Expand Down
16 changes: 12 additions & 4 deletions core/src/main/java/hudson/cli/GroovyshCommand.java
Expand Up @@ -41,7 +41,7 @@
import java.util.ArrayList;

import jline.UnsupportedTerminal;
import jline.Terminal;
import jline.TerminalFactory;
import org.kohsuke.args4j.Argument;

/**
Expand All @@ -65,10 +65,18 @@ protected int run() {

// this being remote means no jline capability is available
System.setProperty("jline.terminal", UnsupportedTerminal.class.getName());
Terminal.resetTerminal();
TerminalFactory.reset();

StringBuilder commandLine = new StringBuilder();
for (String arg : args) {
if (commandLine.length() > 0) {
commandLine.append(" ");
}
commandLine.append(arg);
}

Groovysh shell = createShell(stdin, stdout, stderr);
return shell.run(args.toArray(new String[args.size()]));
return shell.run(commandLine.toString());
}

@SuppressWarnings({"unchecked","rawtypes"})
Expand Down Expand Up @@ -101,7 +109,7 @@ public Object doCall(Object[] args) {
}
};
Groovysh shell = new Groovysh(cl, binding, io, registrar);
shell.getImports().add("import hudson.model.*");
shell.getImports().add("hudson.model.*");

// defaultErrorHook doesn't re-throw IOException, so ShellRunner in
// Groovysh will keep looping forever if we don't terminate when the
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/hudson/util/spring/BeanBuilder.java
Expand Up @@ -39,6 +39,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -132,7 +133,7 @@ public void parse(InputStream script, Binding binding) {
cc.setScriptBaseClass(ClosureScript.class.getName());
GroovyShell shell = new GroovyShell(classLoader,binding,cc);

ClosureScript s = (ClosureScript)shell.parse(script);
ClosureScript s = (ClosureScript)shell.parse(new InputStreamReader(script));
s.setDelegate(this);
s.run();
}
Expand Down Expand Up @@ -336,7 +337,7 @@ public Object call(Object... args) {

GroovyShell shell = classLoader != null ? new GroovyShell(classLoader,b) : new GroovyShell(b);
for (Resource resource : resources) {
shell.evaluate(resource.getInputStream());
shell.evaluate(new InputStreamReader(resource.getInputStream()));
}
}

Expand Down
22 changes: 10 additions & 12 deletions pom.xml
Expand Up @@ -323,7 +323,17 @@ THE SOFTWARE.
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-2.0</artifactId>
<version>1.5-jenkins-3</version>
</dependency>
</dependencies>
<configuration>
<!-- 2.4 not yet supported by plugin but 2.0 works
here so long as we provide explicit version -->
<providerSelection>2.0</providerSelection>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -724,18 +734,6 @@ THE SOFTWARE.
</goals>
</execution>
</executions>
<configuration>
<!-- 1.8 not yet supported by plugin but 1.7 works
here so long as we provide explicit version -->
<providerSelection>1.7</providerSelection>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>

Expand Down
8 changes: 0 additions & 8 deletions test/pom.xml
Expand Up @@ -240,15 +240,7 @@ THE SOFTWARE.
<artifactId>ant-launcher</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-2.0</artifactId>
<version>1.5-jenkins-1</version>
</dependency>
</dependencies>
<configuration>
<providerSelection>2.0</providerSelection>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/cli/GroovyshCommandTest.java
Expand Up @@ -42,7 +42,7 @@ public class GroovyshCommandTest {
@Test public void authentication() throws Exception {
CLICommandInvoker.Result result = new CLICommandInvoker(r, new GroovyshCommand())
.authorizedTo(Jenkins.READ, Jenkins.RUN_SCRIPTS)
.withStdin(new StringInputStream("println(jenkins.model.Jenkins.instance.getClass().name)\nquit\n"))
.withStdin(new StringInputStream("println(jenkins.model.Jenkins.instance.getClass().name)\n:quit\n"))
.invoke();
assertThat(result, succeeded());
assertThat(result, hasNoErrorOutput());
Expand Down

0 comments on commit 54d1cf1

Please sign in to comment.