Class MpsLoadTask

  • All Implemented Interfaces:
    Cloneable
    Direct Known Subclasses:
    CustomMPSLoadTask, GenerateTask, MigrationTask, MpsRunnerTask

    public class MpsLoadTask
    extends org.apache.tools.ant.Task
    Ant task that is capable to execute an MPS-aware 'worker' class. Generally, MPS Ant tasks have very limited classpath (j.m.tool.common and j.m.tool.ant, respectively [ant-mps] and [ant-mps-common]) while actual 'worker' class likely to employ full power of MPS (either with MpsEnvironment or IdeaEnvironment). Hence, the idea of the task is to get worker's classpath ready to use whatever MPS functionality needed. Specific task subclasses may control exact classpath with calculateClassPath(boolean) based on their worker's demand.
    • Constructor Detail

      • MpsLoadTask

        public MpsLoadTask()
      • MpsLoadTask

        public MpsLoadTask​(String workerClass)
    • Method Detail

      • setMpsHome

        public void setMpsHome​(File mpsHome)
      • getMpsHome

        public File getMpsHome()
      • setFailOnError

        public void setFailOnError​(boolean failOnError)
      • setFork

        public void setFork​(boolean fork)
      • addConfiguredRepository

        public void addConfiguredRepository​(RepositoryDataType repo)
      • addConfiguredExclude

        public void addConfiguredExclude​(ExcludeNested excludeInner)
      • addConfiguredMacro

        public void addConfiguredMacro​(Macro macro)
      • getUsePropertiesAsMacro

        public boolean getUsePropertiesAsMacro()
      • setUsePropertiesAsMacro

        public void setUsePropertiesAsMacro​(boolean usePropertiesAsMacro)
      • addConfiguredJvmArg

        public void addConfiguredJvmArg​(Arg jvmArg)
      • addConfiguredJvmArgs

        public void addConfiguredJvmArgs​(JvmArgs jvmArg)
      • addConfiguredPlugin

        public void addConfiguredPlugin​(Plugin plugin)
      • addLibraryJar

        protected final void addLibraryJar​(File file)
        handy alternative to myWhatToDo.addLibraryJar(), with hardcoded knowledge about generator modules distributed in distinct jars
      • setWorker

        public final void setWorker​(String workerClass)
      • getWorker

        public final String getWorker()
      • execute

        public void execute()
                     throws org.apache.tools.ant.BuildException
        Overrides:
        execute in class org.apache.tools.ant.Task
        Throws:
        org.apache.tools.ant.BuildException
      • doInProcessWork

        protected void doInProcessWork​(@NotNull
                                       Class<?> workerClass)
                                throws Exception
        Receives properly loaded worker class and may start worker as appropriate. By default, instantiates an object and fires its no-arg "work" method, see jetbrains.mps.build.ant.MpsLoadTask#instantiateInProcessWorker(Class) and jetbrains.mps.build.ant.MpsLoadTask#invokeInProcessMain(Class, Object)
        Throws:
        Exception
      • instantiateInProcessWorker

        protected Object instantiateInProcessWorker​(@NotNull
                                                    Class<?> workerClass)
                                             throws Exception
        Controls construction of a new worker instance, subclasses may override e.g. to pass arguments to a worker through constructor. This method is part of jetbrains.mps.build.ant.MpsLoadTask#doInProcessWork(Class).
        Throws:
        Exception
      • invokeInProcessMain

        protected void invokeInProcessMain​(@NotNull
                                           Class<?> workerClass,
                                           @NotNull
                                           Object workerInstance)
                                    throws Exception
        Controls execution of a worker code, by default just invokes "work" no-arg method for supplied worker instance. Subclasses may override. This method is part of jetbrains.mps.build.ant.MpsLoadTask#doInProcessWork(Class).
        Throws:
        Exception
      • getMpsHome_Checked

        @Nullable
        protected final File getMpsHome_Checked()
      • calculateClassPath

        protected Set<File> calculateClassPath​(boolean fork)
        subclasses shall override in case they got better idea how worker classpath shall look like. Generally, subclasses use properties of the ant project to access information about environment
      • getWorkerClass

        @Deprecated
        protected String getWorkerClass()
        Deprecated.
        pass worker class name as cons argument or using #setWorker