org.netbeans.modules.java.j2seproject/1 1.53.0 46

org.netbeans.modules.java.j2seproject.api
Class J2SEProjectBuilder

java.lang.Object
  extended by org.netbeans.modules.java.j2seproject.api.J2SEProjectBuilder

public class J2SEProjectBuilder
extends Object

Builder for creating a new J2SE project. Typical usage is:

      new J2SEProjectBuilder(projectFolder, projectName).
      addSourceRoots(sourceFolders).
      addTestRoots(testFolders).
        setMainClass(mainClass).
      build();
 
XXX: Uses Bundle from org.netbeans.modules.java.j2seproject package not to affect existing localizations.

Since:
1.42

Constructor Summary
J2SEProjectBuilder(File projectDirectory, String name)
          Creates a new instance of J2SEProjectBuilder
 
Method Summary
 J2SEProjectBuilder addCompileLibraries(Library... libraries)
          Adds compile time libraries
 J2SEProjectBuilder addDefaultSourceRoots()
          Adds the default source roots, "src" and "test".
 J2SEProjectBuilder addJVMArguments(String jvmArgs)
          Adds a JVM arguments
 J2SEProjectBuilder addRuntimeLibraries(Library... libraries)
          Adds runtime libraries
 J2SEProjectBuilder addSourceRoots(File... sourceRoots)
          Adds source roots into the project
 J2SEProjectBuilder addTestRoots(File... testRoots)
          Adds test roots into the project
 AntProjectHelper build()
          Creates the J2SEProject
 J2SEProjectBuilder setBuildXmlName(String name)
          Sets a name of build.xml file
 J2SEProjectBuilder setDistFolder(String distFolderName)
          Sets a name of dist (build artifact) folder
 J2SEProjectBuilder setJavaPlatform(JavaPlatform platform)
          Sets a platform to be used for a new project
 J2SEProjectBuilder setLibrariesDefinitionFile(String librariesDefinition)
          Sets a library definition file for per project libraries,
 J2SEProjectBuilder setMainClass(String mainClass)
          Sets a main class
 J2SEProjectBuilder setMainClassTemplate(String mainClassTemplatePath)
          Sets a main class template
 J2SEProjectBuilder setManifest(String manifest)
          Sets a path to manifest file
 J2SEProjectBuilder setSourceLevel(SpecificationVersion sourceLevel)
          Sets a source level of the project
 J2SEProjectBuilder skipTests(boolean skipTests)
          Avoids creating the test root folder and adding JUnit dependencies.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

J2SEProjectBuilder

public J2SEProjectBuilder(@NonNull
                          File projectDirectory,
                          @NonNull
                          String name)
Creates a new instance of J2SEProjectBuilder

Parameters:
projectDirectory - the directory in which the project should be created
name - the name of the project
Method Detail

addDefaultSourceRoots

public J2SEProjectBuilder addDefaultSourceRoots()
Adds the default source roots, "src" and "test".

Returns:
the builder

skipTests

public J2SEProjectBuilder skipTests(boolean skipTests)
Avoids creating the test root folder and adding JUnit dependencies. The test folder is still registered so SourceGroupModifier with JavaProjectConstants.SOURCES_HINT_TEST will work later.

Returns:
the builder

addSourceRoots

public J2SEProjectBuilder addSourceRoots(@NonNull
                                         File... sourceRoots)
Adds source roots into the project

Parameters:
sourceRoots - the roots to be added
Returns:
the builder

addTestRoots

public J2SEProjectBuilder addTestRoots(@NonNull
                                       File... testRoots)
Adds test roots into the project

Parameters:
testRoots - the roots to be added
Returns:
the builder

addCompileLibraries

public J2SEProjectBuilder addCompileLibraries(@NonNull
                                              Library... libraries)
Adds compile time libraries

Parameters:
libraries - the libraries to be added to compile classpath.
Returns:
the builder

addRuntimeLibraries

public J2SEProjectBuilder addRuntimeLibraries(@NonNull
                                              Library... libraries)
Adds runtime libraries

Parameters:
libraries - the libraries to be added to runtime classpath.
Returns:
the builder

setMainClass

public J2SEProjectBuilder setMainClass(@NullAllowed
                                       String mainClass)
Sets a main class

Parameters:
mainClass - the fully qualified name of the main class, if null main class is not created
Returns:
the builder

setManifest

public J2SEProjectBuilder setManifest(@NullAllowed
                                      String manifest)
Sets a path to manifest file

Parameters:
manifest - the name (path) to manifest file, if not manifest is not set
Returns:
the builder

setLibrariesDefinitionFile

public J2SEProjectBuilder setLibrariesDefinitionFile(@NullAllowed
                                                     String librariesDefinition)
Sets a library definition file for per project libraries,

Parameters:
librariesDefinition - the name (path) to libraries definition file, if null project libraries are not used
Returns:
the builder

setSourceLevel

public J2SEProjectBuilder setSourceLevel(@NullAllowed
                                         SpecificationVersion sourceLevel)
Sets a source level of the project

Parameters:
sourceLevel - the source level, if null the default source level is used.
Returns:
the builder

setBuildXmlName

public J2SEProjectBuilder setBuildXmlName(@NullAllowed
                                          String name)
Sets a name of build.xml file

Parameters:
name - the name of build.xml file, if null the default 'build.xml' is used
Returns:
the builder

setDistFolder

@NonNull
public J2SEProjectBuilder setDistFolder(@NullAllowed
                                                String distFolderName)
Sets a name of dist (build artifact) folder

Parameters:
distFolderName - the name of the dist folder if null the default 'dist' is used
Returns:
the builder
Since:
1.49

setMainClassTemplate

public J2SEProjectBuilder setMainClassTemplate(@NullAllowed
                                               String mainClassTemplatePath)
Sets a main class template

Parameters:
mainClassTemplatePath - the path to main class template on the system filesystem, if null the default template is used
Returns:
the builder

addJVMArguments

public J2SEProjectBuilder addJVMArguments(@NonNull
                                          String jvmArgs)
Adds a JVM arguments

Parameters:
jvmArgs - the arguments to be added
Returns:
the builder

setJavaPlatform

public J2SEProjectBuilder setJavaPlatform(@NonNull
                                          JavaPlatform platform)
Sets a platform to be used for a new project

Parameters:
platform - to be used
Returns:
the builder
Since:
1.53

build

public AntProjectHelper build()
                       throws IOException
Creates the J2SEProject

Returns:
the AntProjectHelper of the created project
Throws:
IOException - when creation fails

org.netbeans.modules.java.j2seproject/1 1.53.0 46

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.