Maven and Ant

Hi,
when I started my work with MPS I found a page describing how to use maven or ant to automatically execute the MPS generator. I can't find this page anymore. Has maven support been removed?
11 comments
Comment actions Permalink
Hi,

this is important for me and I would really (!!) appreciate an answer.

Has maven support been dropped? And if not, where can I find the plugin and documentation?

Best wishes
Yann Massard
0
Comment actions Permalink
Hi, Yann,

Sorry for the delay with the answer, for some reason notifications from the forum stopped working.

We never had maven support, only ant tasks for generation. They are described in MPS 1.5 Documentation (somehow there were no links from the table of contents to this page, I fixed that).

--
Regards,
Julia
-1
Comment actions Permalink
Thank you so much!! This is what I was searching for.
0
Comment actions Permalink
Hi again,
I have tried using the ant target (using maven-ant-run) but it does not seem to work with MPS2, as the directory structure has changed... There is no more platform folder. Instead, the enerate.ant.task.jar is in the language folder.

I suppose I need to open an issue...

The exception is:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project MPS2-Maven-Test: An Ant BuildException has occured: /Applications/MPS.app is invalid MPS home path: path /Applications/MPS.app/platform/generate.ant.task.jar does not exist or is not a directory or a jar file. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project MPS2-Maven-Test: An Ant BuildException has occured: /Applications/MPS.app is invalid MPS home path: path /Applications/MPS.app/platform/generate.ant.task.jar does not exist or is not a directory or a jar file.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: /Applications/MPS.app is invalid MPS home path: path /Applications/MPS.app/platform/generate.ant.task.jar does not exist or is not a directory or a jar file.
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:283)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 20 more
Caused by: /Users/yamass/Development/MPS-Maven-Test/MPS-2.0-Maven-Test/target/antrun/build-main.xml:5: /Applications/MPS.app is invalid MPS home path: path /Applications/MPS.app/platform/generate.ant.task.jar does not exist or is not a directory or a jar file.
    at jetbrains.mps.build.ant.MpsLoadTask.calculateClassPath(MpsLoadTask.java:254)
    at jetbrains.mps.build.ant.MpsLoadTask.execute(MpsLoadTask.java:128)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:270)
    ... 22 more
prettyPrint();
0
Comment actions Permalink
So now for MPS 1.5:
This time I tried to do it with ant directly (although I am quite sure I got the things right with maven) and it throws the following Exception:

.../build.xml:9: java.lang.NoClassDefFoundError: jetbrains/mps/generator/GenerationListener
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.getConstructor(Class.java:1657)
    at jetbrains.mps.build.ant.MpsLoadTask.execute(MpsLoadTask.java:180)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.lang.ClassNotFoundException: jetbrains.mps.generator.GenerationListener
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 22 more

prettyPrint();

After that I switched to maven again to add the missing dependencies declaratively (see pom.xml). After adding quite a lot of dependencies I got the following exception:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project MPS-Maven-Test: An Ant BuildException has occured: java.lang.Error: java.lang.reflect.InvocationTargetException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: java.lang.Error: java.lang.reflect.InvocationTargetException
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:283)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 20 more
Caused by: /Users/yamass/Development/Idea-Projects/MPS-Maven-Test/target/antrun/build-main.xml:5: java.lang.Error: java.lang.reflect.InvocationTargetException
    at jetbrains.mps.build.ant.MpsLoadTask.execute(MpsLoadTask.java:191)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1397)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1366)
    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:270)
    ... 22 more
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
    at com.intellij.openapi.application.WriteAction.execute(WriteAction.java:46)
    at com.intellij.idea.IdeaTestApplication.getInstance(IdeaTestApplication.java:59)
    at jetbrains.mps.TestMain.configureMPS(TestMain.java:409)
    at jetbrains.mps.build.ant.MpsWorker.setupEnvironment(MpsWorker.java:151)
    at jetbrains.mps.build.ant.MpsWorker.work(MpsWorker.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at jetbrains.mps.build.ant.MpsLoadTask.execute(MpsLoadTask.java:184)
    ... 34 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1079)
    at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
    at com.intellij.ui.GuiUtils.invokeAndWait(GuiUtils.java:366)
    at com.intellij.ui.GuiUtils.runOrInvokeAndWait(GuiUtils.java:374)
    at com.intellij.openapi.application.WriteAction.execute(WriteAction.java:30)
    ... 43 more
Caused by: java.lang.IllegalArgumentException: Missing extension point: com.intellij.ApplicationLoadListener in area null
    at com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.getExtensionPoint(ExtensionsAreaImpl.java:347)
    at com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.getExtensionPoint(ExtensionsAreaImpl.java:37)
    at com.intellij.openapi.application.impl.ApplicationImpl.fireBeforeApplicationLoaded(ApplicationImpl.java:420)
    at com.intellij.openapi.application.impl.ApplicationImpl.load(ApplicationImpl.java:377)
    at com.intellij.idea.IdeaTestApplication$2.run(IdeaTestApplication.java:61)
    at com.intellij.openapi.application.RunResult.run(RunResult.java:37)
    at com.intellij.openapi.application.WriteAction$1$1.run(WriteAction.java:34)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:752)
    at com.intellij.openapi.application.WriteAction$1.run(WriteAction.java:32)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:678)
    at java.awt.EventQueue.access$000(EventQueue.java:86)
    at java.awt.EventQueue$1.run(EventQueue.java:639)
    at java.awt.EventQueue$1.run(EventQueue.java:637)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:648)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
prettyPrint();

Ok, at this point I am quite stuck...

Is there anybody getting ant builds to work?
Help greatly appreciated!

build.xml (474B)
pom.xml (5.5KB)
0
Comment actions Permalink
Hi, Yann,

Thanks for your report. You can download fixed jar with ant tasks for MPS 2.0 M5 here http://confluence.jetbrains.net/download/attachments/39781994/generate.ant.task.jar Replace old jar in languages folder with this one.

--
Regards,
Julia
0
Comment actions Permalink

Julia:

 

our most projects are using maven,

 

why don't support maven tasks for generation?

 

 

0
Comment actions Permalink

The comment you're replying to is 8 years old.

You can call Ant scripts from Maven or Gradle. Maven has certain ideas about how it wants to build projects and what dependency scopes there are. These ideas don't quite match the way MPS works so native Maven support is difficult.

0
Comment actions Permalink
can you explain the Detail about  the "Maven has certain ideas about how it wants to build projects and what dependency scopes there are. These ideas don't quite match the way MPS works so native Maven support is difficult" ?
 
I want to know the detailed reason。
 
thx
0
Comment actions Permalink

1) With Maven you have one language (Java) and you build code written in it. The Java default lifecycle is basically compile, test, package, deploy.

Now, with MPS, the lifecycle is more like: build language L1, use it to build language L2, use L1 and L2 to build L3, ... use all the languages built so far to build a solution written in this language. Maybe testing each of L1...LN in between.

Or: download multiple pre-built languages L1...LN from somewhere, and use them all together to build some solutions.

2) In MPS you have "uses language" dependencies, as in "model M uses a language L that has runtime R". This means that M depends on L if you want to build it, but the built output doesn't need to know anything about L, it only depends on R. In the Maven world the dependency scopes are compile, runtime, provided, and what I just described is kind of like depending on L with a "provided" scope (not compile because compile implies runtime and we don't need L at runtime), and depending on R with "runtime" or "compile" scope.

Due to 1) you will probably need several POMs for one MPS project.

Due to 2) you would need to duplicate all the MPS language/solution dependencies in Maven POMs.

It's all probably doable (meaning there isn't any reason why it would be theoretically impossible) but it's not clear what the benefits are, compared to the much simpler approach of calling out to Ant from Maven.

0

Please sign in to leave a comment.