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.InvokerRequest;
25 import org.apache.maven.api.cli.ParserException;
26 import org.apache.maven.api.cli.ParserRequest;
27 import org.apache.maven.cling.invoker.ProtoLogger;
28 import org.apache.maven.cling.invoker.ProtoLookup;
29 import org.apache.maven.cling.invoker.mvn.MavenParser;
30 import org.apache.maven.cling.invoker.mvn.local.LocalMavenInvoker;
31 import org.apache.maven.jline.JLineMessageBuilderFactory;
32 import org.codehaus.plexus.classworlds.ClassWorld;
33
34
35
36
37 public class MavenCling extends ClingSupport {
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 createInvoker() {
64 return new LocalMavenInvoker(
65 ProtoLookup.builder().addMapping(ClassWorld.class, classWorld).build());
66 }
67
68 @Override
69 protected InvokerRequest parseArguments(String[] args) throws ParserException, IOException {
70 return new MavenParser()
71 .parseInvocation(ParserRequest.mvn(args, new ProtoLogger(), new JLineMessageBuilderFactory())
72 .build());
73 }
74 }