Hello,
J'ai un projet qui compile très bien quand je lance la commande mvn clean install manuellement.
Sauf que je souhaite que cette compilation se fasse via une application Java. Du coup, j'utilise le MavenEmbedder.
J'ai écrit ce code :
Il semble fonctionner, puisque le Reactor de Maven trouve bien les modules à compiler, mais il me jette avec cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Configuration config = new DefaultConfiguration(); config.setUserSettingsFile(new File("...")); config.setClassLoader(Thread.currentThread().getContextClassLoader()); ConfigurationValidationResult validationResult = MavenEmbedder.validateConfiguration(config); if (validationResult.isValid()) { try { MavenEmbedder embedder = new MavenEmbedder(config); MavenExecutionRequest request = new DefaultMavenExecutionRequest(); request.setBaseDirectory("..."); request.setGoals(Arrays.asList(new String[] { "clean", "install" })); MavenExecutionResult result = embedder.execute(request); if (result.hasExceptions()) { List<Exception> exceptions = result.getExceptions(); for (Exception e : exceptions) { e.printStackTrace(); } } } catch (MavenEmbedderException e) { e.printStackTrace(); } }
(notons que le plugin install existe bien sur mon repository local).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 [INFO] Scanning for projects... [INFO] Reactor build order: [INFO] MyApp [INFO] MyApp Commons [INFO] MyApp Client [INFO] MyApp Server [INFO] ------------------------------------------------------------------------ [INFO] Building MyApp [INFO] [INFO] Id: myapp:MyApp:pom:1.0 [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ org.apache.maven.lifecycle.LifecycleExecutionException: Failed to construct build plan for: MyApp Id: myApp:MyApp:pom:1.0 task-segment: [clean, install]. Reason: Failed to resolve plugin for mojo binding: org.apache.maven.plugins:maven-install-plugin:2.2:install at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getLifecycleBindings(DefaultLifecycleExecutor.java:408) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:233) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:201) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:164) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:207) at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:846) at myapp.build.MavenBuilder.runMvnCommand(MavenBuilder.java:60) at myapp.build.ProjectBuilder.go(ProjectBuilder.java:62) at myapp.build.ProjectBuilder.doInBackground(ProjectBuilder.java:77) at myapp.build.ProjectBuilder.doInBackground(ProjectBuilder.java:1) at javax.swing.SwingWorker$1.call(SwingWorker.java:278) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at javax.swing.SwingWorker.run(SwingWorker.java:317) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.maven.lifecycle.plan.LifecyclePlannerException: Failed to resolve plugin for mojo binding: org.apache.maven.plugins:maven-install-plugin:2.2:install at org.apache.maven.lifecycle.plan.DefaultBuildPlanner.loadPluginDescriptor(DefaultBuildPlanner.java:350) at org.apache.maven.lifecycle.plan.DefaultBuildPlanner.findForkModifiers(DefaultBuildPlanner.java:197) at org.apache.maven.lifecycle.plan.DefaultBuildPlanner.addForkedLifecycleModifiers(DefaultBuildPlanner.java:184) at org.apache.maven.lifecycle.plan.DefaultBuildPlanner.constructBuildPlan(DefaultBuildPlanner.java:122) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getLifecycleBindings(DefaultLifecycleExecutor.java:394) ... 16 more Caused by: org.apache.maven.plugin.loader.PluginLoaderException: Failed to load plugin. Reason: The PluginDescriptor for the plugin org.apache.maven.plugins:maven-install-plugin was not found. Should have been in realm: ClassRealm[/plugins/org.apache.maven.plugins:maven-install-plugin:2.2@48/thread:33, parent: null] at org.apache.maven.plugin.loader.DefaultPluginLoader.loadPlugin(DefaultPluginLoader.java:111) at org.apache.maven.plugin.loader.DefaultPluginLoader.loadPlugin(DefaultPluginLoader.java:54) at org.apache.maven.lifecycle.plan.DefaultBuildPlanner.loadPluginDescriptor(DefaultBuildPlanner.java:327) ... 20 more Caused by: org.apache.maven.plugin.PluginManagerException: The PluginDescriptor for the plugin org.apache.maven.plugins:maven-install-plugin was not found. Should have been in realm: ClassRealm[/plugins/org.apache.maven.plugins:maven-install-plugin:2.2@48/thread:33, parent: null] at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginManager.java:355) at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:224) at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:199) at org.apache.maven.plugin.loader.DefaultPluginLoader.loadPlugin(DefaultPluginLoader.java:81) ... 22 more
Qu'ai-je fait de mal ?
Partager