Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@calavera
Created November 12, 2010 22:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save calavera/674775 to your computer and use it in GitHub Desktop.
Save calavera/674775 to your computer and use it in GitHub Desktop.
import hudson.Launcher;
import hudson.Extension;
import hudson.util.FormValidation;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractProject;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.QueryParameter;
import javax.servlet.ServletException;
import java.io.IOException;
class HelloWorldBuilder < Builder
$DataBoundConstructor
def initialize(name:String)
@name = name
end
def perform(build:AbstractBuild, launcher:Launcher, listener:BuildListener)
true
end
$Extension
class DescriptorImpl < BuildStepDescriptor
def configure(req:StaplerRequest, formData:JSONObject)
true
end
end
end
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.376</version>
</parent>
<artifactId>helloWorld</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>Hello plugin</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>never</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase><!--Change this to control when it runs -->
<configuration>
<tasks>
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="mirah_classpath" value="../mirah/dist/mirah-complete.jar:../jruby/lib/jruby-complete.jar"/>
<taskdef name="mirah" classname="org.mirah.ant.Compile" classpath="${mirah_classpath}"/>
<mirah src="hello_world_builder.mirah" classpath="${compile_classpath}:${mirah_classpath}"/>
</tasks>
</configuration>
<goals>
<goal>run</goal><!-- this is to call antrun:run -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.5.5</version>
</dependency>
</dependencies-->
</project>
@cowboyd
Copy link

cowboyd commented Nov 13, 2010

what happened to the annotations?

@calavera
Copy link
Author

it doesn't compile with the annotations :( but it's something to start with and the annotations in mirah will be fully supported soon.

@calavera
Copy link
Author

And... annotations are back and working!

@cowboyd
Copy link

cowboyd commented Nov 15, 2010

So mirah knows to put annotations on the initialize method on the java constructor?

@calavera
Copy link
Author

Yes, the plugin compiles and it's loaded properly, now we have another problem, hudson needs the descriptor uses a generic to know what kind of extension is, builder or publisher for instance, and mirah doesn't support generics right now. I'll talk with headius to see what we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment