1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.start;
20
21 import java.io.IOException;
22 import java.nio.file.Path;
23
24
25
26
27 public class StartIni extends TextFile
28 {
29 private Path basedir;
30
31 public StartIni(Path file) throws IOException
32 {
33 super(file);
34 }
35
36 @Override
37 public void addUniqueLine(String line)
38 {
39 if (line.startsWith("--module="))
40 {
41 int idx = line.indexOf('=');
42 String value = line.substring(idx + 1);
43 for (String part : value.split(","))
44 {
45 super.addUniqueLine("--module=" + expandBaseDir(part));
46 }
47 }
48 else
49 {
50 super.addUniqueLine(expandBaseDir(line));
51 }
52 }
53
54 private String expandBaseDir(String line)
55 {
56 if (line == null)
57 {
58 return line;
59 }
60
61 return line.replace("${start.basedir}",basedir.toString());
62 }
63
64 @Override
65 public void init()
66 {
67 try
68 {
69 basedir = getFile().getParent().toRealPath();
70 }
71 catch (IOException e)
72 {
73 basedir = getFile().getParent().normalize().toAbsolutePath();
74 }
75 }
76
77 public Path getBaseDir()
78 {
79 return basedir;
80 }
81 }