Skip to content

Commit 6b73d1b

Browse files
committed
packaging: document fatjar and stork distribution jooby-project#1785
1 parent 9ea5a52 commit 6b73d1b

File tree

4 files changed

+57
-22
lines changed

4 files changed

+57
-22
lines changed

modules/jooby-cli/build.xml

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/jooby-cli/pom.xml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@
5858
<scope>test</scope>
5959
</dependency>
6060

61+
<dependency>
62+
<groupId>org.mockito</groupId>
63+
<artifactId>mockito-core</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
6167
<dependency>
6268
<groupId>org.jacoco</groupId>
6369
<artifactId>org.jacoco.agent</artifactId>
@@ -69,18 +75,20 @@
6975
<build>
7076
<plugins>
7177
<plugin>
72-
<artifactId>maven-antrun-plugin</artifactId>
78+
<groupId>org.codehaus.mojo</groupId>
79+
<artifactId>properties-maven-plugin</artifactId>
80+
<version>1.0.0</version>
7381
<executions>
7482
<execution>
7583
<phase>generate-resources</phase>
76-
<configuration>
77-
<target>
78-
<ant antfile="${project.basedir}/build.xml"></ant>
79-
</target>
80-
</configuration>
8184
<goals>
82-
<goal>run</goal>
85+
<goal>write-project-properties</goal>
8386
</goals>
87+
<configuration>
88+
<outputFile>
89+
${project.build.outputDirectory}${file.separator}dependencies.properties
90+
</outputFile>
91+
</configuration>
8492
</execution>
8593
</executions>
8694
</plugin>

modules/jooby-cli/src/main/java/io/jooby/internal/cli/CommandContextImpl.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.util.Map;
3030
import java.util.Properties;
3131
import java.util.Set;
32+
import java.util.stream.Collectors;
33+
import java.util.stream.Stream;
3234

3335
public class CommandContextImpl implements Context {
3436

@@ -142,7 +144,13 @@ public Map<String, String> getDependencyMap() throws IOException {
142144
}
143145
}
144146
Map result = new LinkedHashMap<>();
145-
result.putAll(versions);
147+
for (Map.Entry<Object, Object> entry : versions.entrySet()) {
148+
String key = Stream.of(entry.getKey().toString().split("\\.|-"))
149+
.map(name -> Character.toUpperCase(name.charAt(0)) + name.substring(1))
150+
.collect(Collectors.joining());
151+
key = Character.toLowerCase(key.charAt(0)) + key.substring(1);
152+
result.put(key, entry.getValue().toString());
153+
}
146154
return result;
147155
}
148156
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.jooby.internal.cli;
2+
3+
import org.jline.reader.LineReader;
4+
import org.jline.terminal.Terminal;
5+
import org.junit.jupiter.api.Test;
6+
7+
import java.io.IOException;
8+
import java.io.PrintWriter;
9+
import java.util.Map;
10+
11+
import static org.junit.jupiter.api.Assertions.assertNotNull;
12+
import static org.mockito.Mockito.mock;
13+
import static org.mockito.Mockito.when;
14+
15+
public class CommandContextImplTest {
16+
17+
@Test
18+
public void shouldLoadDependencyFile() throws IOException {
19+
PrintWriter writer = mock(PrintWriter.class);
20+
21+
Terminal terminal = mock(Terminal.class);
22+
when(terminal.writer()).thenReturn(writer);
23+
24+
LineReader reader = mock(LineReader.class);
25+
when(reader.getTerminal()).thenReturn(terminal);
26+
27+
CommandContextImpl ctx = new CommandContextImpl(reader, "2.8.5");
28+
29+
Map<String, String> dependencyMap = ctx.getDependencyMap();
30+
assertNotNull(dependencyMap);
31+
assertNotNull(dependencyMap.get("mavenTilesPluginVersion"));
32+
}
33+
}

0 commit comments

Comments
 (0)