com.atlassian.plugin.test
Class PluginJarBuilder

java.lang.Object
  extended by com.atlassian.plugin.test.PluginJarBuilder

public class PluginJarBuilder
extends Object

Builds a plugin jar, including optionally compiling simple Java code


Constructor Summary
PluginJarBuilder()
          Creates the builder
PluginJarBuilder(String name)
          Creates the builder
PluginJarBuilder(String name, ClassLoader classLoader)
          Creates the builder
 
Method Summary
 PluginJarBuilder addFile(String path, File file)
          Adds a file to the jar
 PluginJarBuilder addFormattedJava(String className, String... lines)
           
 PluginJarBuilder addFormattedResource(String path, String... lines)
          Adds a resource in the jar as lines.
 PluginJarBuilder addJava(String className, String code)
          Adds a Java class in source form.
 PluginJarBuilder addPluginInformation(String key, String name, String version)
           
 PluginJarBuilder addPluginInformation(String key, String name, String version, int pluginsVersion)
           
 PluginJarBuilder addPluginInformation(String key, String name, String version, int pluginsVersion, Map<String,String> params)
           
 PluginJarBuilder addResource(String path, String contents)
          Adds a resource in the jar from a string
 File build()
          Builds a jar file from the provided information.
 File build(File baseDir)
          Builds a jar file from the provided information.
 File buildWithNoManifest()
           
 byte[] getClassFile(String className)
           
 ClassLoader getClassLoader()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginJarBuilder

public PluginJarBuilder()
Creates the builder


PluginJarBuilder

public PluginJarBuilder(String name)
Creates the builder

Parameters:
name - The plugin name

PluginJarBuilder

public PluginJarBuilder(String name,
                        ClassLoader classLoader)
Creates the builder

Parameters:
name - The plugin name
Method Detail

addFormattedJava

public PluginJarBuilder addFormattedJava(String className,
                                         String... lines)
                                  throws Exception
Throws:
Exception

addJava

public PluginJarBuilder addJava(String className,
                                String code)
                         throws Exception
Adds a Java class in source form. Will compile the source code.

Parameters:
className - The class name
code - The code to compile
Returns:
The builder
Throws:
Exception

getClassFile

public byte[] getClassFile(String className)
                    throws NoSuchFieldException,
                           IllegalAccessException
Throws:
NoSuchFieldException
IllegalAccessException

addResource

public PluginJarBuilder addResource(String path,
                                    String contents)
Adds a resource in the jar from a string

Parameters:
path - The path for the jar entry
contents - The contents of the file to create
Returns:

addFormattedResource

public PluginJarBuilder addFormattedResource(String path,
                                             String... lines)
Adds a resource in the jar as lines. Single quotes are converted to double quotes.

Parameters:
path - The path for the jar entry
lines - The contents of the file to create
Returns:

addPluginInformation

public PluginJarBuilder addPluginInformation(String key,
                                             String name,
                                             String version)

addPluginInformation

public PluginJarBuilder addPluginInformation(String key,
                                             String name,
                                             String version,
                                             int pluginsVersion)

addPluginInformation

public PluginJarBuilder addPluginInformation(String key,
                                             String name,
                                             String version,
                                             int pluginsVersion,
                                             Map<String,String> params)

addFile

public PluginJarBuilder addFile(String path,
                                File file)
                         throws IOException
Adds a file to the jar

Parameters:
path - The path for the entry
file - The file to add
Returns:
Throws:
IOException

build

public File build()
           throws IOException
Builds a jar file from the provided information. The file name is not guarenteed to match the jar name, as it is created as a temporary file.

Returns:
The created jar plugin
Throws:
IOException

buildWithNoManifest

public File buildWithNoManifest()
                         throws IOException
Throws:
IOException

build

public File build(File baseDir)
           throws IOException
Builds a jar file from the provided information. The file name is not guarenteed to match the jar name, as it is created as a temporary file.

Parameters:
baseDir - The base directory for generated plugin files
Returns:
The created jar plugin
Throws:
IOException

getClassLoader

public ClassLoader getClassLoader()


Copyright © 2011 Atlassian. All Rights Reserved.