1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.cling;
20
21 import java.io.IOException;
22
23 import org.apache.maven.api.cli.Invoker;
24 import org.apache.maven.api.cli.ParserException;
25 import org.apache.maven.api.cli.mvn.MavenInvokerRequest;
26 import org.apache.maven.api.cli.mvn.MavenOptions;
27 import org.apache.maven.cling.invoker.ProtoLogger;
28 import org.apache.maven.cling.invoker.ProtoLookup;
29 import org.apache.maven.cling.invoker.mvn.DefaultMavenParser;
30 import org.apache.maven.cling.invoker.mvn.local.DefaultLocalMavenInvoker;
31 import org.apache.maven.jline.JLineMessageBuilderFactory;
32 import org.codehaus.plexus.classworlds.ClassWorld;
33
34
35
36
37 public class MavenCling extends ClingSupport<MavenOptions, MavenInvokerRequest<MavenOptions>> {
38
39
40
41
42 public static void main(String[] args) throws IOException {
43 int exitCode = new MavenCling().run(args);
44 System.exit(exitCode);
45 }
46
47
48
49
50 public static int main(String[] args, ClassWorld world) throws IOException {
51 return new MavenCling(world).run(args);
52 }
53
54 public MavenCling() {
55 super();
56 }
57
58 public MavenCling(ClassWorld classWorld) {
59 super(classWorld);
60 }
61
62 @Override
63 protected Invoker<MavenInvokerRequest<MavenOptions>> createInvoker() {
64 return new DefaultLocalMavenInvoker(
65 ProtoLookup.builder().addMapping(ClassWorld.class, classWorld).build());
66 }
67
68 @Override
69 protected MavenInvokerRequest<MavenOptions> parseArguments(String[] args) throws ParserException, IOException {
70 return new DefaultMavenParser().mvn(args, new ProtoLogger(), new JLineMessageBuilderFactory());
71 }
72 }