package hudson.maven;

import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.JobDescriptor;
import hudson.model.RunMap;
import hudson.model.RunMap.Constructor;

import java.io.File;
import java.io.IOException;

/**
 * @author Kohsuke Kawaguchi
 */
public final class MavenJob extends AbstractProject<MavenJob,MavenBuild> {
    public MavenJob(Hudson parent, String name) {
        super(parent, name);
    }

    protected void onLoad(Hudson root, String name) throws IOException {
        super.onLoad(root, name);

        this.builds = new RunMap<MavenBuild>();
        this.builds.load(this,new Constructor<MavenBuild>() {
            public MavenBuild create(File dir) throws IOException {
                return new MavenBuild(MavenJob.this,dir);
            }
        });
    }

    @Override
    public MavenBuild newBuild() throws IOException {
        MavenBuild lastBuild = new MavenBuild(this);
        builds.put(lastBuild);
        return lastBuild;
    }

    public JobDescriptor<MavenJob,MavenBuild> getDescriptor() {
        return DESCRIPTOR;
    }

    public static final JobDescriptor<MavenJob,MavenBuild> DESCRIPTOR = new JobDescriptor<MavenJob,MavenBuild>(MavenJob.class) {
        public String getDisplayName() {
            return "Building Maven2 project (alpha)";
        }

        public MavenJob newInstance(String name) {
            return new MavenJob(Hudson.getInstance(),name);
        }
    };
}

@@ -1455,11 +1455,80 @@
 %7D%0A    %7D;
+%0A%0A    static %7B%0A        XSTREAM.alias(%22maven2%22, MavenJob.class);%0A    %7D
 %0A%7D%0A

use a bit more sensible tag name in config.xml