Package spoon

Class MavenLauncher

java.lang.Object
spoon.Launcher
spoon.MavenLauncher
All Implemented Interfaces:
SpoonAPI

public class MavenLauncher extends Launcher
Create a Spoon launcher from a maven pom file
  • Constructor Details

    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType)
      MavenLauncher constructor assuming either an environment variable M2_HOME, or that mvn command exists in PATH.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, Pattern profileFilter)
      MavenLauncher constructor assuming either an environment variable M2_HOME, or that mvn command exists in PATH.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      profileFilter - regular expression of profiles to include in the built model
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, boolean forceRefresh)
      MavenLauncher constructor assuming either an environment variable M2_HOME, or that mvn command exists in PATH.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      forceRefresh - force the regeneration of classpath
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, boolean forceRefresh, Pattern profileFilter)
      MavenLauncher constructor assuming either an environment variable M2_HOME, or that mvn command exists in PATH.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      forceRefresh - force the regeneration of classpath
      profileFilter - regular expression of profiles to include in the built model
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String mvnHome)
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      mvnHome - Path to maven install
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String mvnHome, Pattern profileFilter)
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      mvnHome - Path to maven install
      profileFilter - regular expression of profiles to include in the built model
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String mvnHome, boolean forceRefresh)
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      mvnHome - Path to maven install
      forceRefresh - force the regeneration of classpath
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String mvnHome, boolean forceRefresh, Pattern profileFilter)
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      mvnHome - Path to maven install
      forceRefresh - force the regeneration of classpath
      profileFilter - regular expression of profiles to include in the built model
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String[] classpath)
      MavenLauncher constructor that skips maven invocation building classpath.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      classpath - String array containing the classpath elements
    • MavenLauncher

      public MavenLauncher(String mavenProject, MavenLauncher.SOURCE_TYPE sourceType, String[] classpath, Pattern profileFilter)
      MavenLauncher constructor that skips maven invocation building classpath.
      Parameters:
      mavenProject - the path to the root of the project
      sourceType - the source type (App, test, or all)
      classpath - String array containing the classpath elements
      profileFilter - regular expression of profiles to include in the built model
  • Method Details

    • getPomFile

      public SpoonPom getPomFile()
      Returns:
      SpoonPom corresponding to the pom file used by the launcher
    • setEnvironmentVariable

      public void setEnvironmentVariable(String key, String value)
      Adds an environment variable to the maven invocation.


      Note that you need to call rebuildClasspath() after calling this method for changes to take effect.

      Parameters:
      key - the name of the environment variable
      value - its value
      See Also:
      #rebuildClasspath() for changes to take effect
    • reportClassPathMode

      protected void reportClassPathMode()
      Overrides:
      reportClassPathMode in class Launcher
    • rebuildClasspath

      public void rebuildClasspath()
      Triggers regeneration of the classpath that is used for building the model, based on pom.xml