getSupportedBuildpackLevels(){
56 | return buildpackLevels;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/client/src/main/java/dev/snowdrop/buildpack/utils/OperatingSytem.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.utils;
2 |
3 | public enum OperatingSytem {
4 |
5 | WIN,
6 | LINUX,
7 | MAC,
8 | UNKNOWN;
9 |
10 | private static OperatingSytem os;
11 |
12 | public static OperatingSytem getOperationSystem() {
13 | if (os == null) {
14 | String osName = System.getProperty("os.name").toLowerCase();
15 | if (osName.contains("win")) {
16 | os = WIN;
17 | } else if (osName.contains("nix") || osName.contains("nux") || osName.contains("aix")) {
18 | os = LINUX;
19 | } else if (osName.contains("mac")) {
20 | os = MAC;
21 | } else {
22 | os = UNKNOWN;
23 | }
24 | }
25 | return os;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/config/CacheConfigTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.config;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertFalse;
5 | import static org.junit.jupiter.api.Assertions.assertNull;
6 | import static org.junit.jupiter.api.Assertions.assertTrue;
7 |
8 | import org.junit.jupiter.api.Test;
9 |
10 | public class CacheConfigTest {
11 | @Test
12 | void constructorTest(){
13 | CacheConfig c1 = new CacheConfig("fred", null);
14 | assertTrue(c1.getDeleteCacheAfterBuild());
15 | assertEquals("fred", c1.getCacheVolumeName());
16 |
17 | CacheConfig c2 = new CacheConfig(null, null);
18 | assertTrue(c2.getDeleteCacheAfterBuild());
19 | assertNull(c2.getCacheVolumeName());
20 |
21 | CacheConfig c3 = new CacheConfig("fish", false);
22 | assertFalse(c3.getDeleteCacheAfterBuild());
23 | assertEquals("fish", c3.getCacheVolumeName());
24 |
25 | CacheConfig c4 = new CacheConfig("stilettos", true);
26 | assertTrue(c4.getDeleteCacheAfterBuild());
27 | assertEquals("stilettos", c4.getCacheVolumeName());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/config/ImageReferenceTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.config;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertThrows;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Arrays;
8 | import java.util.List;
9 |
10 | import org.junit.jupiter.api.Test;
11 |
12 | public class ImageReferenceTest {
13 |
14 | private static class P {
15 | public String val;
16 | public String expected;
17 | public P(String a, String b){
18 | this.val = a;
19 | this.expected = b;
20 | }
21 | }
22 |
23 | @Test
24 | void checkNullImageReference(){
25 | IllegalStateException is = assertThrows(IllegalStateException.class, () -> new ImageReference(null));
26 | }
27 |
28 | @Test
29 | void checkImageReference(){
30 | ImageReference ir2 = new ImageReference("wibble");
31 | assertEquals("docker.io/wibble:latest", ir2.getCanonicalReference());
32 | }
33 |
34 | @Test
35 | void checkAll(){
36 |
37 | //validate permutations/combinations of docker image reference elements
38 |
39 | // [[host/]|[host:port/]]repo[:tag][@digest]
40 |
41 | //slighly complicated by needing to differentiate between stiletto/fish and localhost/fish, where the 2nd has a host
42 | //also, no host, means docker.io, and index.docker.io means docker.io
43 |
44 | List hosts = listOf( new P("","docker.io"), new P("docker.io", "docker.io"), new P("localhost", "localhost"), new P("index.docker.io", "docker.io"), new P("quay.io", "quay.io"));
45 | List
ports = listOf( new P("", null), new P("9999", "9999") );
46 | List repos = Arrays.asList(new String[]{"fish", "fish/wibble", "fish/wibble/stiletto", "fish/wibble/stiletto/kitten"});
47 | List tags = listOf( new P("", "latest"), new P("tag", "tag"));
48 | List
digests = listOf( new P("", null), new P("sha256:d51bd558b181b918fe759c3166bc2d7c6e1c6b4b695a1a0bd7abfbc6bb2f89e4", "sha256:d51bd558b181b918fe759c3166bc2d7c6e1c6b4b695a1a0bd7abfbc6bb2f89e4"));
49 |
50 | for(P host: hosts){
51 | for(P port: ports){
52 | for(String repo : repos){
53 | for(P tag : tags){
54 | for(P digest : digests){
55 |
56 | //we can't do port, if we don't have host!
57 | if(host.val.equals("") && !port.val.equals("")) continue;
58 |
59 | //assemble the test ref according to docker reference rules.
60 | String testRef = host.val + (host.val.equals("")?"":(!port.val.equals("")?":"+port.val+"/":"/")) + repo + (tag.val.equals("")?"":":"+tag.val) + (digest.val.equals("")?"":"@"+digest.val);
61 |
62 | //assemble the expected ref (easier, as host is now mandatory)
63 | String expected = host.expected + (port.expected!=null?":"+port.expected+"/":"/") + repo + ((tag.val.equals("")&&!digest.val.equals(""))?"":":"+tag.expected) + (digest.expected!=null?"@"+digest.expected:"");
64 |
65 | //generate reference from test ref string.
66 | ImageReference ref = new ImageReference(testRef);
67 |
68 | //validate properties.
69 | assertEquals(expected, ref.getCanonicalReference(), "Test: "+testRef+" Expected: "+expected);
70 | assertEquals(host.expected, ref.getHost());
71 | assertEquals(port.expected, ref.getPort());
72 | assertEquals(repo, ref.getRepo());
73 | if(tag.val.equals("")){
74 | if(digest.val.equals("")){
75 | assertEquals(tag.expected, ref.getTag());
76 | }else{
77 | assertEquals(null, ref.getTag());
78 | }
79 | } else {
80 | assertEquals(tag.expected, ref.getTag());
81 | }
82 | assertEquals(digest.expected, ref.getDigest());
83 | }
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
90 | private List
listOf(P... p){
91 | return Arrays.asList(p);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/config/LogConfigTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.config;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertFalse;
5 | import static org.junit.jupiter.api.Assertions.assertNotNull;
6 | import static org.junit.jupiter.api.Assertions.assertTrue;
7 |
8 | import org.junit.jupiter.api.Test;
9 | import org.junit.jupiter.api.extension.ExtendWith;
10 | import org.mockito.Mock;
11 | import org.mockito.junit.jupiter.MockitoExtension;
12 |
13 | import dev.snowdrop.buildpack.Logger;
14 |
15 | @ExtendWith(MockitoExtension.class)
16 | public class LogConfigTest {
17 | @Test
18 | void checkLogLevel() {
19 | LogConfig lc1 = new LogConfig(null, null, null);
20 | assertEquals("info", lc1.getLogLevel());
21 | LogConfig lc2 = new LogConfig("debug", null, null);
22 | assertEquals("debug", lc2.getLogLevel());
23 | }
24 |
25 | @Test
26 | void checkUseTimestamps() {
27 | LogConfig lc1 = new LogConfig(null, null, null);
28 | assertTrue(lc1.getUseTimestamps());
29 | LogConfig lc2 = new LogConfig(null, true, null);
30 | assertTrue(lc2.getUseTimestamps());
31 | LogConfig lc3 = new LogConfig(null, false, null);
32 | assertFalse(lc3.getUseTimestamps());
33 | }
34 |
35 | @Test
36 | void checkLogger(@Mock Logger logger) {
37 | LogConfig lc1 = new LogConfig(null, null, null);
38 | assertNotNull(lc1.getLogger());
39 | LogConfig lc2 = new LogConfig(null, null, logger);
40 | assertEquals(logger, lc2.getLogger());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/config/PlatformConfigTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.config;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertFalse;
5 | import static org.junit.jupiter.api.Assertions.assertNotNull;
6 | import static org.junit.jupiter.api.Assertions.assertNull;
7 | import static org.junit.jupiter.api.Assertions.assertTrue;
8 |
9 | import java.util.HashMap;
10 | import java.util.Map;
11 |
12 | import org.junit.jupiter.api.Test;
13 |
14 | public class PlatformConfigTest {
15 | @Test
16 | void checkPlatformLevel(){
17 | PlatformConfig pc1 = new PlatformConfig(null, null, null, null, null);
18 | assertNotNull(pc1.getPlatformLevel());
19 |
20 | PlatformConfig pc2 = new PlatformConfig("0.7", null, null, null, null);
21 | assertNotNull(pc2.getPlatformLevel());
22 | assertEquals("0.7", pc2.getPlatformLevel());
23 | }
24 |
25 | @Test
26 | void checkEnv() {
27 | PlatformConfig pc1 = new PlatformConfig(null, null, null, null, null);
28 | assertNotNull(pc1.getEnvironment());
29 |
30 | Map m = new HashMap<>();
31 | PlatformConfig pc2 = new PlatformConfig(null, null, m, null, null);
32 | }
33 |
34 | @Test
35 | void checkLifecycleImage() {
36 | PlatformConfig pc1 = new PlatformConfig(null, null, null, null, null);
37 | assertNull(pc1.getLifecycleImage());
38 |
39 | PlatformConfig pc2 = new PlatformConfig(null, new ImageReference("fish"), null, null, null);
40 | assertNotNull(pc2.getLifecycleImage());
41 | assertEquals(new ImageReference("fish").getCanonicalReference(), pc2.getLifecycleImage().getCanonicalReference());
42 | }
43 |
44 | @Test
45 | void checkTrustBuilder() {
46 | PlatformConfig pc1 = new PlatformConfig(null, null, null, null, null);
47 | assertNull(pc1.getTrustBuilder());
48 |
49 | PlatformConfig pc2 = new PlatformConfig(null, null, null, true, null);
50 | assertTrue(pc2.getTrustBuilder());
51 |
52 | PlatformConfig pc3 = new PlatformConfig(null, null, null, false, null);
53 | assertFalse(pc3.getTrustBuilder());
54 | }
55 |
56 | @Test
57 | void checkDebugScript() {
58 | PlatformConfig pc1 = new PlatformConfig(null, null, null, null, null);
59 | assertNull(pc1.getPhaseDebugScript());
60 |
61 | PlatformConfig pc2 = new PlatformConfig(null, null, null, true, "echo 'hello world'");
62 | assertNotNull(pc2.getPhaseDebugScript());
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/docker/ContainerEntryTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.docker;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.ByteArrayInputStream;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 | import java.nio.charset.StandardCharsets;
11 |
12 | import org.junit.jupiter.api.Test;
13 |
14 | public class ContainerEntryTest {
15 | //simple test to catch if we change the public API by mistake.
16 | @Test
17 | void apiRegressionTest() throws Exception{
18 | ContainerEntry ce = new ContainerEntry(){
19 |
20 | @Override
21 | public String getPath() {
22 | return "fish";
23 | }
24 |
25 | @Override
26 | public long getSize() {
27 | return 1337;
28 | }
29 |
30 | @Override
31 | public Integer getMode() {
32 | return 0755;
33 | }
34 |
35 | @Override
36 | public DataSupplier getDataSupplier() {
37 | return new DataSupplier(){
38 | @Override
39 | public InputStream getData() {
40 | return new ByteArrayInputStream("FISH".getBytes());
41 | }
42 | };
43 | }
44 |
45 | };
46 |
47 | assertEquals("fish", ce.getPath());
48 | assertEquals(1337, ce.getSize());
49 | assertEquals(0755, ce.getMode());
50 |
51 |
52 | assertNotNull(ce.getDataSupplier().getData());
53 | BufferedReader br = new BufferedReader(new InputStreamReader(ce.getDataSupplier().getData(), StandardCharsets.UTF_8));
54 | assertEquals("FISH",br.readLine());
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/docker/ContentTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.docker;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
5 |
6 | import java.util.List;
7 |
8 | import org.junit.jupiter.api.Test;
9 |
10 | public class ContentTest {
11 | //simple test to catch if we change the public API by mistake.
12 | @Test
13 | void apiRegressionTest() throws Exception{
14 | Content c = new Content(){
15 | @Override
16 | public List getContainerEntries() {
17 | return new StringContent("/fish", 0777, "stiletto").getContainerEntries();
18 | }
19 |
20 | };
21 |
22 | assertNotNull(c.getContainerEntries());
23 | assertEquals(1,c.getContainerEntries().size());
24 | ContainerEntry a = c.getContainerEntries().get(0);
25 | assertEquals("/fish", a.getPath());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/docker/DockerClientUtilsTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.docker;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
5 |
6 | import org.junit.jupiter.api.Test;
7 | import org.junit.jupiter.api.extension.ExtendWith;
8 | import org.mockito.junit.jupiter.MockitoExtension;
9 |
10 | import com.github.dockerjava.api.DockerClient;
11 |
12 | import dev.snowdrop.buildpack.config.HostAndSocketConfig;
13 |
14 | @ExtendWith(MockitoExtension.class)
15 | public class DockerClientUtilsTest {
16 |
17 | @Test
18 | void getDockerHost() {
19 | String val = System.getenv("DOCKER_HOST");
20 |
21 | HostAndSocketConfig result = DockerClientUtils.probeContainerRuntime(null);
22 |
23 | if (val != null) {
24 | assertEquals(val, result.getHost().get());
25 | }
26 |
27 | assertNotNull(result);
28 | }
29 |
30 | @Test
31 | void getDockerClient() {
32 | DockerClient dc = DockerClientUtils.getDockerClient();
33 | assertNotNull(dc);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/docker/ImageUtilsTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.docker;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
5 | import static org.mockito.ArgumentMatchers.eq;
6 | import static org.mockito.Mockito.verify;
7 | import static org.mockito.Mockito.when;
8 | import static org.mockito.Mockito.never;
9 | import static org.mockito.Mockito.lenient;
10 | import static org.mockito.Mockito.atLeast;
11 |
12 | import java.util.ArrayList;
13 | import java.util.HashMap;
14 | import java.util.List;
15 | import java.util.Map;
16 |
17 | import org.junit.jupiter.api.Test;
18 | import org.junit.jupiter.api.extension.ExtendWith;
19 | import org.mockito.ArgumentMatchers;
20 | import org.mockito.Mock;
21 | import org.mockito.junit.jupiter.MockitoExtension;
22 |
23 | import com.github.dockerjava.api.DockerClient;
24 | import com.github.dockerjava.api.command.InspectImageCmd;
25 | import com.github.dockerjava.api.command.InspectImageResponse;
26 | import com.github.dockerjava.api.command.ListImagesCmd;
27 | import com.github.dockerjava.api.command.PullImageCmd;
28 | import com.github.dockerjava.api.model.ContainerConfig;
29 | import com.github.dockerjava.api.model.Image;
30 |
31 | import dev.snowdrop.buildpack.config.DockerConfig;
32 | import dev.snowdrop.buildpack.config.ImageReference;
33 | import dev.snowdrop.buildpack.docker.ImageUtils.ImageInfo;
34 |
35 | @ExtendWith(MockitoExtension.class)
36 | public class ImageUtilsTest {
37 |
38 |
39 | @Test
40 | void testInspectImage(@Mock DockerClient dc,
41 | @Mock InspectImageCmd iic,
42 | @Mock InspectImageResponse iir,
43 | @Mock ContainerConfig cc
44 | ) {
45 |
46 | ImageReference test = new ImageReference("test");
47 | String imageName = "test:latest";
48 |
49 | when(dc.inspectImageCmd(eq(imageName))).thenReturn(iic);
50 | when(iic.exec()).thenReturn(iir);
51 |
52 | when(iir.getId()).thenReturn("id");
53 | when(iir.getConfig()).thenReturn(cc);
54 | when(cc.getEnv()).thenReturn(new String[] {"one","two"});
55 | Map labels = new HashMap();
56 | labels.put("l1", "v1");
57 | when(cc.getLabels()).thenReturn(labels);
58 |
59 | ImageInfo ii = ImageUtils.inspectImage(dc, test);
60 |
61 | assertEquals(ii.id,"id");
62 | assertArrayEquals(ii.env, new String[] {"one","two"} );
63 | assertEquals(ii.labels, labels);
64 |
65 | verify(iic).exec();
66 | }
67 |
68 | @Test
69 | void testPullImageSingleUnknown(@Mock DockerConfig config,
70 | @Mock DockerClient dc,
71 | @Mock ListImagesCmd lic,
72 | @Mock PullImageCmd pic) throws InterruptedException {
73 |
74 | ImageReference test = new ImageReference("test");
75 | String imageName = "test:latest";
76 |
77 | lenient().when(config.getDockerClient()).thenReturn(dc);
78 | lenient().when(config.getPullPolicy()).thenReturn(DockerConfig.PullPolicy.IF_NOT_PRESENT);
79 | lenient().when(dc.listImagesCmd()).thenReturn(lic);
80 | lenient().when(lic.exec()).thenReturn(new ArrayList());
81 |
82 | when(dc.pullImageCmd(eq(imageName))).thenReturn(pic);
83 |
84 | ImageUtils.pullImages(config, test);
85 |
86 | verify(pic, atLeast(1)).exec(ArgumentMatchers.any());
87 | }
88 |
89 | @Test
90 | void testPullImageSingleKnown(@Mock DockerConfig config,
91 | @Mock DockerClient dc,
92 | @Mock ListImagesCmd lic,
93 | @Mock Image i,
94 | @Mock PullImageCmd pic) throws InterruptedException {
95 |
96 | ImageReference test = new ImageReference("test:v1");
97 | String imageName = "test:v1";
98 |
99 | lenient().when(config.getDockerClient()).thenReturn(dc);
100 | lenient().when(config.getPullPolicy()).thenReturn(DockerConfig.PullPolicy.IF_NOT_PRESENT);
101 | lenient().when(dc.listImagesCmd()).thenReturn(lic);
102 |
103 | List li = new ArrayList();
104 | li.add(i);
105 | when(lic.exec()).thenReturn(li);
106 | when(i.getRepoTags()).thenReturn(new String[] {imageName});
107 |
108 | //(dc.pullImageCmd(eq(imageName))).thenReturn(pic);
109 |
110 | ImageUtils.pullImages(config, test);
111 |
112 | verify(dc, never()).pullImageCmd(ArgumentMatchers.any());
113 | }
114 |
115 | @Test
116 | void testPullImageSingleKnownNoTag(@Mock DockerConfig config,
117 | @Mock DockerClient dc,
118 | @Mock ListImagesCmd lic,
119 | @Mock Image i,
120 | @Mock PullImageCmd pic) throws InterruptedException {
121 |
122 | ImageReference test = new ImageReference("test");
123 | String imageName = "test:latest";
124 |
125 | lenient().when(config.getDockerClient()).thenReturn(dc);
126 | lenient().when(config.getPullPolicy()).thenReturn(DockerConfig.PullPolicy.IF_NOT_PRESENT);
127 | lenient().when(dc.listImagesCmd()).thenReturn(lic);
128 |
129 | List li = new ArrayList();
130 | li.add(i);
131 | when(lic.exec()).thenReturn(li);
132 | when(i.getRepoTags()).thenReturn(new String[] {imageName});
133 |
134 | when(dc.pullImageCmd(eq(imageName))).thenReturn(pic);
135 |
136 | ImageUtils.pullImages(config, test);
137 |
138 | verify(pic, atLeast(1)).exec(ArgumentMatchers.any());
139 | }
140 |
141 | @Test
142 | void testPullImageSingleKnownLatest(@Mock DockerConfig config,
143 | @Mock DockerClient dc,
144 | @Mock ListImagesCmd lic,
145 | @Mock Image i,
146 | @Mock PullImageCmd pic) throws InterruptedException {
147 |
148 | ImageReference test = new ImageReference("test:latest");
149 | String imageName = "test:latest";
150 |
151 | lenient().when(config.getDockerClient()).thenReturn(dc);
152 | lenient().when(config.getPullPolicy()).thenReturn(DockerConfig.PullPolicy.IF_NOT_PRESENT);
153 | lenient().when(dc.listImagesCmd()).thenReturn(lic);
154 |
155 | List li = new ArrayList();
156 | li.add(i);
157 | when(lic.exec()).thenReturn(li);
158 | when(i.getRepoTags()).thenReturn(new String[] {imageName});
159 |
160 | when(dc.pullImageCmd(eq(imageName))).thenReturn(pic);
161 |
162 | ImageUtils.pullImages(config, test);
163 |
164 | verify(pic, atLeast(1)).exec(ArgumentMatchers.any());
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/lifecycle/ContainerStatusTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.lifecycle;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import org.junit.jupiter.api.Test;
6 |
7 | public class ContainerStatusTest {
8 | @Test
9 | void testContainerStatus(){
10 | ContainerStatus cs1 = ContainerStatus.of(66, "fish");
11 | assertEquals(66,cs1.getRc());
12 | assertEquals("fish", cs1.getContainerId());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/utils/JsonUtilsTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.utils;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 | import static org.junit.jupiter.api.Assertions.assertNotNull;
5 | import static org.junit.jupiter.api.Assertions.fail;
6 |
7 | import java.util.List;
8 |
9 | import org.junit.jupiter.api.Test;
10 |
11 | import com.fasterxml.jackson.core.JsonProcessingException;
12 | import com.fasterxml.jackson.databind.DeserializationFeature;
13 | import com.fasterxml.jackson.databind.JsonMappingException;
14 | import com.fasterxml.jackson.databind.JsonNode;
15 | import com.fasterxml.jackson.databind.ObjectMapper;
16 |
17 | public class JsonUtilsTest {
18 | @Test
19 | void testJsonUtils() {
20 |
21 | String json = "{\"heels\":[\"kitten\",\"stiletto\",\"wedge\"], \"aNumber\":1337, \"aWord\":\"wibble\", \"sizes\":[11,12], \"models\":{\"patent\":{\"color\":\"red\"}}}}";
22 |
23 | ObjectMapper om = new ObjectMapper();
24 | om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
25 | try {
26 | JsonNode root = om.readTree(json);
27 |
28 | String word = JsonUtils.getValue(root, "aWord");
29 | assertEquals("wibble", word);
30 |
31 | String nestedWord = JsonUtils.getValue(root, "models/patent/color");
32 | assertEquals("red",nestedWord);
33 |
34 | String number = JsonUtils.getValue(root, "aNumber");
35 | assertEquals("1337", number);
36 |
37 | List wordList = JsonUtils.getArray(root, "heels");
38 | assertNotNull(wordList);
39 | assertEquals(3, wordList.size());
40 |
41 | List numberList = JsonUtils.getArray(root, "sizes");
42 | assertNotNull(numberList);
43 | assertEquals(2, numberList.size());
44 | } catch (JsonMappingException e) {
45 | fail(e);
46 | } catch (JsonProcessingException e) {
47 | fail(e);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/client/src/test/java/dev/snowdrop/buildpack/utils/LifecycleArgsTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.buildpack.utils;
2 |
3 | import static org.junit.jupiter.api.Assertions.assertEquals;
4 |
5 | import org.junit.jupiter.api.Test;
6 |
7 | public class LifecycleArgsTest {
8 | @Test
9 | void testLifecycleArgs(){
10 | LifecycleArgs la1 = new LifecycleArgs("/command", null);
11 | assertEquals(1, la1.toList().size());
12 | assertEquals("/command", la1.toList().get(0));
13 |
14 | la1.addArg("-daemon");
15 | assertEquals(2, la1.toList().size());
16 |
17 | la1.addArg("-flag", "value");
18 | assertEquals(4, la1.toList().size());
19 |
20 | LifecycleArgs la2 = new LifecycleArgs("/command", "image-name");
21 | assertEquals(2, la2.toList().size());
22 | assertEquals("/command", la2.toList().get(0));
23 | assertEquals("image-name", la2.toList().get(1));
24 |
25 | la2.addArg("-flag","value");
26 | assertEquals(4, la2.toList().size());
27 | assertEquals("image-name", la2.toList().get(3));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/build-me/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 | !**/src/main/**/target/
4 | !**/src/test/**/target/
5 |
6 | ### IntelliJ IDEA ###
7 | .idea
8 | *.iws
9 | *.iml
10 | *.ipr
11 |
12 | ### VS Code ###
13 | .vscode/
14 |
15 | ### Mac OS ###
16 | .DS_Store
17 |
18 | .env
--------------------------------------------------------------------------------
/samples/build-me/README.md:
--------------------------------------------------------------------------------
1 | # Buildpack Builder config example
2 |
3 | Example of a java project able to build a Quarkus, Spring Boot, ... project
4 | using the DSL `BuildConfig.builder()`
5 |
6 | To use it, configure the following mandatory environment variables pointing to a project (example: [hello-quarkus](../hello-quarkus), [hello-spring](../hello-spring)) to be built as a container image
7 |
8 | ```bash
9 | export PROJECT_PATH=
10 | # can be without registry or a full registry reference with host, port(optional), path & tag
11 | export IMAGE_REF=
12 | ```
13 |
14 | If you plan to push your image to a registry, then set your registry credential using these variables:
15 | ```bash
16 | export REGISTRY_USERNAME=""
17 | export REGISTRY_PASSWORD=""
18 | export REGISTRY_ADDRESS="docker.io"
19 | ```
20 |
21 | If you prefer that lifecycle don't access the mounted docker socket but talk directly with the container registry to build the image, then set to `false` the following variable:
22 | ```shell
23 | export USE_DAEMON=false
24 | ```
25 |
26 | Execute this command in a terminal:
27 | ```bash
28 | mvn compile exec:java
29 | ```
30 |
31 | You can also pass the `BP_` or `CNB_` environment variables:
32 | ```bash
33 | export BP_JVM_VERSION="21"
34 | export BP_MAVEN_BUILT_ARTIFACT="target/quarkus-app/lib/ target/quarkus-app/*.jar target/quarkus-app/app/ target/quarkus-app/quarkus"
35 | export CNB_LOG_LEVEL=debug
36 | etc
37 | ```
--------------------------------------------------------------------------------
/samples/build-me/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | dev.snowdrop
8 | build-me
9 | Snowdrop :: Java Buildpack Client :: Samples :: Build me
10 | 1.0-SNAPSHOT
11 |
12 |
13 | 21
14 | 21
15 | UTF-8
16 |
17 |
18 |
19 |
20 | dev.snowdrop
21 | buildpack-client
22 | 0.0.14
23 |
24 |
25 | org.projectlombok
26 | lombok
27 | 1.18.30
28 | provided
29 |
30 |
31 |
32 |
33 | com.github.docker-java
34 | docker-java-core
35 | 3.4.0
36 |
37 |
38 |
39 |
40 | org.slf4j
41 | slf4j-simple
42 | 1.7.30
43 |
44 |
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-compiler-plugin
50 | 3.11.0
51 |
52 |
53 | -proc:full
54 |
55 |
56 |
57 | org.codehaus.mojo
58 | exec-maven-plugin
59 | 3.5.0
60 |
61 | dev.snowdrop.BuildMe
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/samples/build-me/src/main/java/dev/snowdrop/BuildMe.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import java.io.File;
4 | import java.util.*;
5 | import java.util.stream.Collectors;
6 |
7 | import dev.snowdrop.buildpack.*;
8 | import dev.snowdrop.buildpack.config.*;
9 |
10 | public class BuildMe {
11 |
12 | public static void main(String... args) {
13 |
14 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack","debug");
15 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.docker","debug");
16 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
17 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");
18 |
19 | String IMAGE_REF = Optional.ofNullable(System.getenv("IMAGE_REF"))
20 | .orElseThrow(() -> new IllegalStateException("Missing env var: IMAGE_REF"));
21 | String PROJECT_PATH = Optional.ofNullable(System.getenv("PROJECT_PATH"))
22 | .orElseThrow(() -> new IllegalStateException("Missing env var: PROJECT_PATH"));
23 | String USE_DAEMON = Optional.ofNullable(System.getenv("USE_DAEMON"))
24 | .orElse("true");
25 |
26 | Map envMap = System.getenv().entrySet().stream()
27 | .filter(entry -> entry.getKey().startsWith("BP_") || entry.getKey().startsWith("CNB_"))
28 | .collect(Collectors.toMap(
29 | Map.Entry::getKey,
30 | Map.Entry::getValue,
31 | (oldValue, newValue) -> newValue,
32 | HashMap::new
33 | ));
34 |
35 | List authInfo = new ArrayList<>();
36 | if(System.getenv("REGISTRY_ADDRESS")!=null){
37 | String registry = System.getenv("REGISTRY_ADDRESS");
38 | String username = System.getenv("REGISTRY_USER");
39 | String password = System.getenv("REGISTRY_PASS");
40 | RegistryAuthConfig authConfig = RegistryAuthConfig.builder()
41 | .withRegistryAddress(registry)
42 | .withUsername(username)
43 | .withPassword(password)
44 | .build();
45 | authInfo.add(authConfig);
46 | }
47 |
48 | int exitCode = BuildConfig.builder()
49 | .withBuilderImage(new ImageReference("paketocommunity/builder-ubi-base:latest"))
50 | .withOutputImage(new ImageReference(IMAGE_REF))
51 | .withNewPlatformConfig()
52 | .withEnvironment(envMap)
53 | .endPlatformConfig()
54 | .withNewDockerConfig()
55 | .withAuthConfigs(authInfo)
56 | .withUseDaemon(Boolean.parseBoolean(USE_DAEMON))
57 | .endDockerConfig()
58 | .withNewLogConfig()
59 | .withLogger(new SystemLogger())
60 | .withLogLevel("debug")
61 | .and()
62 | .addNewFileContentApplication(new File(PROJECT_PATH))
63 | .build()
64 | .getExitCode();
65 |
66 | System.exit(exitCode);
67 | }
68 | }
--------------------------------------------------------------------------------
/samples/hello-quarkus/.dockerignore:
--------------------------------------------------------------------------------
1 | *
2 | !target/*-runner
3 | !target/*-runner.jar
4 | !target/lib/*
5 | !target/quarkus-app/*
--------------------------------------------------------------------------------
/samples/hello-quarkus/.gitignore:
--------------------------------------------------------------------------------
1 | #Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | release.properties
7 | .flattened-pom.xml
8 |
9 | # Eclipse
10 | .project
11 | .classpath
12 | .settings/
13 | bin/
14 |
15 | # IntelliJ
16 | .idea
17 | *.ipr
18 | *.iml
19 | *.iws
20 |
21 | # NetBeans
22 | nb-configuration.xml
23 |
24 | # Visual Studio Code
25 | .vscode
26 | .factorypath
27 |
28 | # OSX
29 | .DS_Store
30 |
31 | # Vim
32 | *.swp
33 | *.swo
34 |
35 | # patch
36 | *.orig
37 | *.rej
38 |
39 | # Local environment
40 | .env
41 |
42 | # Plugin directory
43 | /.quarkus/cli/plugins/
44 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/.mvn/wrapper/.gitignore:
--------------------------------------------------------------------------------
1 | maven-wrapper.jar
2 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.net.Authenticator;
23 | import java.net.PasswordAuthentication;
24 | import java.net.URL;
25 | import java.nio.file.Files;
26 | import java.nio.file.Path;
27 | import java.nio.file.Paths;
28 | import java.nio.file.StandardCopyOption;
29 |
30 | public final class MavenWrapperDownloader
31 | {
32 | private static final String WRAPPER_VERSION = "3.2.0";
33 |
34 | private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
35 |
36 | public static void main( String[] args )
37 | {
38 | log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
39 |
40 | if ( args.length != 2 )
41 | {
42 | System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
43 | System.exit( 1 );
44 | }
45 |
46 | try
47 | {
48 | log( " - Downloader started" );
49 | final URL wrapperUrl = new URL( args[0] );
50 | final String jarPath = args[1].replace( "..", "" ); // Sanitize path
51 | final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
52 | downloadFileFromURL( wrapperUrl, wrapperJarPath );
53 | log( "Done" );
54 | }
55 | catch ( IOException e )
56 | {
57 | System.err.println( "- Error downloading: " + e.getMessage() );
58 | if ( VERBOSE )
59 | {
60 | e.printStackTrace();
61 | }
62 | System.exit( 1 );
63 | }
64 | }
65 |
66 | private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
67 | throws IOException
68 | {
69 | log( " - Downloading to: " + wrapperJarPath );
70 | if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
71 | {
72 | final String username = System.getenv( "MVNW_USERNAME" );
73 | final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
74 | Authenticator.setDefault( new Authenticator()
75 | {
76 | @Override
77 | protected PasswordAuthentication getPasswordAuthentication()
78 | {
79 | return new PasswordAuthentication( username, password );
80 | }
81 | } );
82 | }
83 | try ( InputStream inStream = wrapperUrl.openStream() )
84 | {
85 | Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
86 | }
87 | log( " - Downloader complete" );
88 | }
89 |
90 | private static void log( String msg )
91 | {
92 | if ( VERBOSE )
93 | {
94 | System.out.println( msg );
95 | }
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
19 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/README.md:
--------------------------------------------------------------------------------
1 | # quarkus-hello
2 |
3 | This project uses Quarkus, the Supersonic Subatomic Java Framework.
4 |
5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6 |
7 | ## Running the application in dev mode
8 |
9 | You can run your application in dev mode that enables live coding using:
10 | ```shell script
11 | ./mvnw compile quarkus:dev
12 | ```
13 |
14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
15 |
16 | ## Packaging and running the application
17 |
18 | The application can be packaged using:
19 | ```shell script
20 | ./mvnw package
21 | ```
22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
24 |
25 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
26 |
27 | If you want to build an _über-jar_, execute the following command:
28 | ```shell script
29 | ./mvnw package -Dquarkus.package.type=uber-jar
30 | ```
31 |
32 | The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
33 |
34 | ## Creating a native executable
35 |
36 | You can create a native executable using:
37 | ```shell script
38 | ./mvnw package -Dnative
39 | ```
40 |
41 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
42 | ```shell script
43 | ./mvnw package -Dnative -Dquarkus.native.container-build=true
44 | ```
45 |
46 | You can then execute your native executable with: `./target/quarkus-hello-1.0-runner`
47 |
48 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
49 |
50 | ## Related Guides
51 |
52 | - Kubernetes ([guide](https://quarkus.io/guides/kubernetes)): Generate Kubernetes resources from annotations
53 | - RESTEasy Reactive ([guide](https://quarkus.io/guides/resteasy-reactive)): A Jakarta REST implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
54 |
55 | ## Provided Code
56 |
57 | ### RESTEasy Reactive
58 |
59 | Easily start your Reactive RESTful Web Services
60 |
61 | [Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources)
62 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/id-debug.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # A simple script to dump uid/gid & /workspace permissions during a build.
4 | #
5 | # This can be very useful when implementing a platform, to determine if /workspace
6 | # has permissions for the executing uid/gid.
7 |
8 | id
9 | ls -aln /workspace
10 |
11 | exit 0
12 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/pack.java:
--------------------------------------------------------------------------------
1 | ///usr/bin/env jbang "$0" "$@" ; exit $?
2 |
3 | //REPOS mavencentral,jitpack
4 | //DEPS org.slf4j:slf4j-simple:1.7.30
5 | //DEPS ${env.CURRENT_WORKFLOW_DEP:dev.snowdrop:buildpack-client:0.0.15-SNAPSHOT}
6 |
7 |
8 | import java.io.File;
9 | import dev.snowdrop.buildpack.*;
10 | import dev.snowdrop.buildpack.config.*;
11 | import dev.snowdrop.buildpack.docker.*;
12 | import java.util.Map;
13 |
14 | import com.github.dockerjava.api.DockerClient;
15 | import com.github.dockerjava.api.command.InspectImageResponse;
16 | import com.github.dockerjava.api.command.PullImageResultCallback;
17 | import com.github.dockerjava.api.model.Image;
18 | import com.github.dockerjava.api.exception.DockerClientException;
19 | import com.github.dockerjava.api.exception.NotFoundException;
20 |
21 | public class pack {
22 |
23 | public static void main(String... args) {
24 |
25 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack","debug");
26 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.docker","debug");
27 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
28 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");
29 |
30 | String debugScript = "#!/bin/bash\n" +
31 | "echo \"DEBUG INFO\"\n" +
32 | "echo \"Root Perms\"\n" +
33 | "stat -c \"%A $a %u %g %n\" /*\n" +
34 | "echo \"Layer dir Content\"\n" +
35 | "ls -lar /layers\n" +
36 | "echo \"Workspace dir Content\"\n" +
37 | "ls -lar /workspace\n" +
38 | "echo \"Analyzed toml\"\n" +
39 | "ls -la /layers\n" +
40 | "cat /layers/analyzed.toml\n" +
41 | "LC=$1\n" +
42 | "shift\n" +
43 | "$LC \"$@\"";
44 |
45 | String JDK="17";
46 |
47 | Map envMap = new java.util.HashMap<>();
48 | envMap.put("BP_JVM_VERSION",JDK);
49 |
50 | int exitCode = BuildConfig.builder()
51 | //.withBuilderImage(new ImageReference("docker.io/paketocommunity/builder-ubi-base"))
52 | .withBuilderImage(new ImageReference("quay.io/ozzydweller/testbuilders:paketo-default"))
53 | .withOutputImage(new ImageReference("snowdrop/hello-quarkus:jvm"+JDK))
54 | .withNewDockerConfig()
55 | .withPullPolicy(DockerConfig.PullPolicy.IF_NOT_PRESENT)
56 | .and()
57 | .withNewPlatformConfig()
58 | .withPhaseDebugScript(debugScript)
59 | .withEnvironment(envMap)
60 | .and()
61 | .withNewLogConfig()
62 | .withLogger(new SystemLogger())
63 | .withLogLevel("debug")
64 | .and()
65 | .addNewFileContentApplication(new File("."))
66 | .build()
67 | .getExitCode();
68 |
69 | System.exit(exitCode);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | dev.snowdrop
6 | quarkus-hello
7 | Snowdrop :: Java Buildpack Client :: Samples :: Hello Quarkus
8 | 1.0
9 |
10 | 3.12.1
11 | UTF-8
12 | UTF-8
13 | quarkus-bom
14 | io.quarkus.platform
15 | 3.8.3
16 | true
17 | 3.2.5
18 |
19 |
20 |
21 |
22 | ${quarkus.platform.group-id}
23 | ${quarkus.platform.artifact-id}
24 | ${quarkus.platform.version}
25 | pom
26 | import
27 |
28 |
29 |
30 |
31 |
32 | io.quarkus
33 | quarkus-kubernetes
34 |
35 |
36 | io.quarkus
37 | quarkus-resteasy-reactive
38 |
39 |
40 | io.quarkus
41 | quarkus-container-image-buildpack
42 |
43 |
44 | io.quarkus
45 | quarkus-arc
46 |
47 |
48 | io.quarkus
49 | quarkus-junit5
50 | test
51 |
52 |
53 | io.rest-assured
54 | rest-assured
55 | test
56 |
57 |
58 |
59 |
60 |
61 | ${quarkus.platform.group-id}
62 | quarkus-maven-plugin
63 | ${quarkus.platform.version}
64 | true
65 |
66 |
67 |
68 | build
69 | generate-code
70 | generate-code-tests
71 |
72 |
73 |
74 |
75 |
76 | maven-compiler-plugin
77 | ${compiler-plugin.version}
78 |
79 |
80 | -parameters
81 |
82 |
83 |
84 |
85 | org.codehaus.mojo
86 | exec-maven-plugin
87 | 1.5.0
88 |
89 |
90 | compile
91 |
92 | exec
93 |
94 |
95 | /bin/sh
96 | ${basedir}
97 |
98 | ${basedir}/id-debug.sh
99 |
100 |
101 |
102 |
103 |
104 |
105 | maven-surefire-plugin
106 | ${surefire-plugin.version}
107 |
108 |
109 | org.jboss.logmanager.LogManager
110 | ${maven.home}
111 |
112 |
113 |
114 |
115 | maven-failsafe-plugin
116 | ${surefire-plugin.version}
117 |
118 |
119 |
120 | integration-test
121 | verify
122 |
123 |
124 |
125 |
126 |
127 | ${project.build.directory}/${project.build.finalName}-runner
128 | org.jboss.logmanager.LogManager
129 | ${maven.home}
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | native
138 |
139 |
140 | native
141 |
142 |
143 |
144 | false
145 | native
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/docker/Dockerfile.jvm:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-hello-jvm .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-jvm
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18 | # Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19 | # when running the container
20 | #
21 | # Then run the container using :
22 | #
23 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-jvm
24 | #
25 | # This image uses the `run-java.sh` script to run the application.
26 | # This scripts computes the command line to execute your Java application, and
27 | # includes memory/GC tuning.
28 | # You can configure the behavior using the following environment properties:
29 | # - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30 | # - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31 | # in JAVA_OPTS (example: "-Dsome.property=foo")
32 | # - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33 | # used to calculate a default maximal heap memory based on a containers restriction.
34 | # If used in a container without any memory constraints for the container then this
35 | # option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36 | # of the container available memory as set here. The default is `50` which means 50%
37 | # of the available memory is used as an upper boundary. You can skip this mechanism by
38 | # setting this value to `0` in which case no `-Xmx` option is added.
39 | # - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40 | # is used to calculate a default initial heap memory based on the maximum heap memory.
41 | # If used in a container without any memory constraints for the container then this
42 | # option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43 | # of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44 | # is used as the initial heap size. You can skip this mechanism by setting this value
45 | # to `0` in which case no `-Xms` option is added (example: "25")
46 | # - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47 | # This is used to calculate the maximum value of the initial heap memory. If used in
48 | # a container without any memory constraints for the container then this option has
49 | # no effect. If there is a memory constraint then `-Xms` is limited to the value set
50 | # here. The default is 4096MB which means the calculated value of `-Xms` never will
51 | # be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52 | # - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53 | # when things are happening. This option, if set to true, will set
54 | # `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55 | # - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56 | # true").
57 | # - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58 | # - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59 | # https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60 | # - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61 | # - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62 | # (example: "20")
63 | # - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64 | # (example: "40")
65 | # - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66 | # (example: "4")
67 | # - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68 | # previous GC times. (example: "90")
69 | # - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70 | # - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71 | # - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72 | # contain the necessary JRE command-line options to specify the required GC, which
73 | # will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74 | # - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
75 | # - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
76 | # - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77 | # accessed directly. (example: "foo.example.com,bar.example.com")
78 | #
79 | ###
80 | FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
81 |
82 | ENV LANGUAGE='en_US:en'
83 |
84 |
85 | # We make four distinct layers so if there are application changes the library layers can be re-used
86 | COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
87 | COPY --chown=185 target/quarkus-app/*.jar /deployments/
88 | COPY --chown=185 target/quarkus-app/app/ /deployments/app/
89 | COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
90 |
91 | EXPOSE 8080
92 | USER 185
93 | ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
94 | ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
95 |
96 | ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
97 |
98 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/docker/Dockerfile.legacy-jar:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dquarkus.package.type=legacy-jar
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus-hello-legacy-jar .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-legacy-jar
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18 | # Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19 | # when running the container
20 | #
21 | # Then run the container using :
22 | #
23 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-legacy-jar
24 | #
25 | # This image uses the `run-java.sh` script to run the application.
26 | # This scripts computes the command line to execute your Java application, and
27 | # includes memory/GC tuning.
28 | # You can configure the behavior using the following environment properties:
29 | # - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30 | # - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31 | # in JAVA_OPTS (example: "-Dsome.property=foo")
32 | # - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33 | # used to calculate a default maximal heap memory based on a containers restriction.
34 | # If used in a container without any memory constraints for the container then this
35 | # option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36 | # of the container available memory as set here. The default is `50` which means 50%
37 | # of the available memory is used as an upper boundary. You can skip this mechanism by
38 | # setting this value to `0` in which case no `-Xmx` option is added.
39 | # - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40 | # is used to calculate a default initial heap memory based on the maximum heap memory.
41 | # If used in a container without any memory constraints for the container then this
42 | # option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43 | # of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44 | # is used as the initial heap size. You can skip this mechanism by setting this value
45 | # to `0` in which case no `-Xms` option is added (example: "25")
46 | # - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47 | # This is used to calculate the maximum value of the initial heap memory. If used in
48 | # a container without any memory constraints for the container then this option has
49 | # no effect. If there is a memory constraint then `-Xms` is limited to the value set
50 | # here. The default is 4096MB which means the calculated value of `-Xms` never will
51 | # be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52 | # - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53 | # when things are happening. This option, if set to true, will set
54 | # `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55 | # - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56 | # true").
57 | # - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58 | # - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59 | # https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60 | # - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61 | # - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62 | # (example: "20")
63 | # - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64 | # (example: "40")
65 | # - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66 | # (example: "4")
67 | # - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68 | # previous GC times. (example: "90")
69 | # - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70 | # - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71 | # - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72 | # contain the necessary JRE command-line options to specify the required GC, which
73 | # will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74 | # - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
75 | # - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
76 | # - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77 | # accessed directly. (example: "foo.example.com,bar.example.com")
78 | #
79 | ###
80 | FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
81 |
82 | ENV LANGUAGE='en_US:en'
83 |
84 |
85 | COPY target/lib/* /deployments/lib/
86 | COPY target/*-runner.jar /deployments/quarkus-run.jar
87 |
88 | EXPOSE 8080
89 | USER 185
90 | ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
91 | ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
92 |
93 | ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
94 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/docker/Dockerfile.native:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-hello .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello
15 | #
16 | ###
17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
18 | WORKDIR /work/
19 | RUN chown 1001 /work \
20 | && chmod "g+rwX" /work \
21 | && chown 1001:root /work
22 | COPY --chown=1001:root target/*-runner /work/application
23 |
24 | EXPOSE 8080
25 | USER 1001
26 |
27 | ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
28 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/docker/Dockerfile.native-micro:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3 | # It uses a micro base image, tuned for Quarkus native executables.
4 | # It reduces the size of the resulting container image.
5 | # Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
6 | #
7 | # Before building the container image run:
8 | #
9 | # ./mvnw package -Dnative
10 | #
11 | # Then, build the image with:
12 | #
13 | # docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/quarkus-hello .
14 | #
15 | # Then run the container using:
16 | #
17 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello
18 | #
19 | ###
20 | FROM quay.io/quarkus/quarkus-micro-image:2.0
21 | WORKDIR /work/
22 | RUN chown 1001 /work \
23 | && chmod "g+rwX" /work \
24 | && chown 1001:root /work
25 | COPY --chown=1001:root target/*-runner /work/application
26 |
27 | EXPOSE 8080
28 | USER 1001
29 |
30 | ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
31 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/java/dev/snowdrop/GreetingResource.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import jakarta.ws.rs.GET;
4 | import jakarta.ws.rs.Path;
5 | import jakarta.ws.rs.Produces;
6 | import jakarta.ws.rs.core.MediaType;
7 |
8 | @Path("/hello")
9 | public class GreetingResource {
10 |
11 | @GET
12 | @Produces(MediaType.TEXT_PLAIN)
13 | public String hello() {
14 | return "Hello from RESTEasy Reactive";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/snowdrop/java-buildpack-client/38fc7150e74795017d2333a915602e7a2f4b19b2/samples/hello-quarkus/src/main/resources/application.properties
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/test/java/dev/snowdrop/GreetingResourceIT.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import io.quarkus.test.junit.QuarkusIntegrationTest;
4 |
5 | @QuarkusIntegrationTest
6 | class GreetingResourceIT extends GreetingResourceTest {
7 | // Execute the same tests but in packaged mode.
8 | }
9 |
--------------------------------------------------------------------------------
/samples/hello-quarkus/src/test/java/dev/snowdrop/GreetingResourceTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import io.quarkus.test.junit.QuarkusTest;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static io.restassured.RestAssured.given;
7 | import static org.hamcrest.CoreMatchers.is;
8 |
9 | @QuarkusTest
10 | class GreetingResourceTest {
11 | @Test
12 | void testHelloEndpoint() {
13 | given()
14 | .when().get("/hello")
15 | .then()
16 | .statusCode(200)
17 | .body(is("Hello from RESTEasy Reactive"));
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/samples/hello-spring/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/samples/hello-spring/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/snowdrop/java-buildpack-client/38fc7150e74795017d2333a915602e7a2f4b19b2/samples/hello-spring/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/samples/hello-spring/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/samples/hello-spring/pack.java:
--------------------------------------------------------------------------------
1 | ///usr/bin/env jbang "$0" "$@" ; exit $?
2 |
3 | //REPOS mavencentral,jitpack
4 | //DEPS org.slf4j:slf4j-simple:1.7.30
5 | //DEPS ${env.CURRENT_WORKFLOW_DEP:dev.snowdrop:buildpack-client:0.0.15-SNAPSHOT}
6 |
7 | import java.io.File;
8 | import java.util.HashMap;
9 | import dev.snowdrop.buildpack.*;
10 | import dev.snowdrop.buildpack.config.*;
11 | import dev.snowdrop.buildpack.docker.*;
12 |
13 | public class pack {
14 |
15 | public static void main(String... args) {
16 |
17 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack","debug");
18 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.docker","debug");
19 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
20 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");
21 |
22 | HashMap env = new HashMap<>();
23 |
24 | int exitCode = BuildConfig.builder()
25 | .withBuilderImage(new ImageReference("docker.io/paketocommunity/builder-ubi-base"))
26 | .withOutputImage(new ImageReference("snowdrop/hello-spring"))
27 | .withNewLogConfig()
28 | .withLogger(new SystemLogger())
29 | .withLogLevel("debug")
30 | .and()
31 | .withNewPlatformConfig()
32 | .withEnvironment(env)
33 | .and()
34 | .addNewFileContentApplication(new File("."))
35 | .build()
36 | .getExitCode();
37 |
38 | System.exit(exitCode);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/samples/hello-spring/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.1
9 |
10 |
11 | dev.snowdrop
12 | hello-spring
13 | 0.0.3-SNAPSHOT
14 | Snowdrop :: Java Buildpack Client :: Samples :: Hello Spring
15 | Demo project for Spring Boot with Java Buildpack client script
16 |
17 | 11
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-test
28 | test
29 |
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-maven-plugin
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/samples/hello-spring/src/main/java/dev/snowdrop/hellospring/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.hellospring;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/samples/hello-spring/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/samples/testcases/README.md:
--------------------------------------------------------------------------------
1 | ## Github Workflow test projects
2 |
3 | These projects are driven by the github workflows multiplatform-test and multiplatform-registry-test, which drive this library with a variety of java levels and os platforms against a variety of container runtimes (podman 4/5 and docker), to ensure we are able to build in each case.
--------------------------------------------------------------------------------
/samples/testcases/RunRegistryTest.java:
--------------------------------------------------------------------------------
1 | ///usr/bin/env jbang "$0" "$@" ; exit $?
2 |
3 | //REPOS mavencentral,jitpack
4 | //DEPS org.slf4j:slf4j-simple:1.7.30
5 | //DEPS ${env.CURRENT_WORKFLOW_DEP}
6 |
7 |
8 | import java.io.File;
9 | import dev.snowdrop.buildpack.*;
10 | import dev.snowdrop.buildpack.config.*;
11 | import dev.snowdrop.buildpack.docker.*;
12 | import dev.snowdrop.buildpack.utils.OperatingSytem;
13 | import java.util.ArrayList;
14 | import java.util.Map;
15 | import java.util.HashMap;
16 | import java.util.Optional;
17 | import java.util.List;
18 |
19 | import com.github.dockerjava.api.DockerClient;
20 | import com.github.dockerjava.api.command.InspectImageResponse;
21 | import com.github.dockerjava.api.command.PullImageResultCallback;
22 | import com.github.dockerjava.api.model.Image;
23 | import com.github.dockerjava.api.exception.DockerClientException;
24 | import com.github.dockerjava.api.exception.NotFoundException;
25 |
26 | public class RunRegistryTest {
27 |
28 | public static void main(String... args) {
29 | try{
30 | run();
31 | }catch(Exception e){
32 | System.err.println("Error during run...");
33 | e.printStackTrace();
34 | System.exit(250);
35 | }
36 | }
37 |
38 | private static void run() throws Exception {
39 |
40 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack","debug");
41 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.docker","debug");
42 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
43 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");
44 |
45 | String debugScript = "#!/bin/bash\n" +
46 | "echo \"DEBUG INFO\"\n" +
47 | "echo \"Root Perms\"\n" +
48 | "stat -c \"%A $a %u %g %n\" /*\n" +
49 | "echo \"Layer dir Content\"\n" +
50 | "ls -lar /layers\n" +
51 | "echo \"Workspace dir Content\"\n" +
52 | "ls -lar /workspace\n" +
53 | "echo \"Analyzed toml\"\n" +
54 | "cat /layers/analyzed.toml\n" +
55 | "echo \"Run toml\"\n" +
56 | "cat /cnb/run.toml\n" +
57 | "echo \"Stack toml\"\n" +
58 | "cat /cnb/stack.toml\n" +
59 | "echo \"DEBUG END\"\n" +
60 | "LC=$1\n" +
61 | "shift\n" +
62 | "$LC \"$@\"";
63 |
64 | String projectPath = Optional.ofNullable(System.getenv("PROJECT_PATH")).orElse(".");
65 | String JDK = Optional.ofNullable(System.getenv("JDK")).orElse("17");
66 | String builderImage = Optional.ofNullable(System.getenv("BUILDER_IMAGE")).orElse("quay.io/ozzydweller/testbuilders:debug-exporter");
67 | String outputImage = Optional.ofNullable(System.getenv("OUTPUT_IMAGE")).orElse("snowdrop/hello-quarkus:jvm"+JDK);
68 |
69 | System.out.println("RunTest Building path '"+projectPath+"' using '"+builderImage+"' requesting jdk '"+JDK+"'");
70 |
71 | Map envMap = new HashMap<>();
72 | envMap.put("BP_JVM_VERSION",JDK);
73 |
74 | List authInfo = new ArrayList<>();
75 |
76 | if(System.getenv("REGISTRY_ADDRESS")!=null){
77 | String registry = System.getenv("REGISTRY_ADDRESS");
78 | String username = System.getenv("REGISTRY_USER");
79 | String password = System.getenv("REGISTRY_PASS");
80 | RegistryAuthConfig authConfig = RegistryAuthConfig.builder()
81 | .withRegistryAddress(registry)
82 | .withUsername(username)
83 | .withPassword(password)
84 | .build();
85 | authInfo.add(authConfig);
86 | }
87 |
88 | int exitCode = 0;
89 |
90 | OperatingSytem os = OperatingSytem.getOperationSystem();
91 | if(os != OperatingSytem.WIN) {
92 | System.out.println("Building "+outputImage+" using "+authInfo.size()+" credentials, with builder "+builderImage);
93 | exitCode = BuildConfig.builder()
94 | .withBuilderImage(new ImageReference(builderImage))
95 | .withOutputImage(new ImageReference(outputImage))
96 | .withNewDockerConfig()
97 | .withAuthConfigs(authInfo)
98 | .withUseDaemon(false)
99 | .and()
100 | .withNewPlatformConfig()
101 | .withEnvironment(envMap)
102 | //.withPlatformLevel("0.12")
103 | //.withPhaseDebugScript(debugScript)
104 | .and()
105 | .withNewLogConfig()
106 | .withLogger(new SystemLogger())
107 | //.withLogLevel("debug")
108 | .and()
109 | .addNewFileContentApplication(new File(projectPath))
110 | .build()
111 | .getExitCode();
112 | }else{
113 | //github windows runner cannot run linux docker containers,
114 | //so we'll just test the ability for the library to correctly talk
115 | //to the docker daemon.
116 | DockerClient dc = DockerClientUtils.getDockerClient();
117 | try{
118 | dc.pingCmd().exec();
119 | }catch(Exception e){
120 | throw new RuntimeException("Unable to verify docker settings", e);
121 | }
122 | }
123 |
124 | System.exit(exitCode);
125 | }
126 | }
--------------------------------------------------------------------------------
/samples/testcases/RunTest.java:
--------------------------------------------------------------------------------
1 | ///usr/bin/env jbang "$0" "$@" ; exit $?
2 |
3 | //REPOS mavencentral,jitpack
4 | //DEPS org.slf4j:slf4j-simple:1.7.30
5 | //DEPS ${env.CURRENT_WORKFLOW_DEP}
6 |
7 |
8 | import java.io.File;
9 | import dev.snowdrop.buildpack.*;
10 | import dev.snowdrop.buildpack.config.*;
11 | import dev.snowdrop.buildpack.docker.*;
12 | import dev.snowdrop.buildpack.utils.OperatingSytem;
13 | import java.util.Map;
14 | import java.util.HashMap;
15 | import java.util.Optional;
16 |
17 | import com.github.dockerjava.api.DockerClient;
18 | import com.github.dockerjava.api.command.InspectImageResponse;
19 | import com.github.dockerjava.api.command.PullImageResultCallback;
20 | import com.github.dockerjava.api.model.Image;
21 | import com.github.dockerjava.api.exception.DockerClientException;
22 | import com.github.dockerjava.api.exception.NotFoundException;
23 |
24 | public class RunTest {
25 |
26 | public static void main(String... args) {
27 | try{
28 | run();
29 | }catch(Exception e){
30 | System.err.println("Error during run...");
31 | e.printStackTrace();
32 | System.exit(250);
33 | }
34 | }
35 |
36 | private static void run() throws Exception {
37 |
38 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack","debug");
39 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.docker","debug");
40 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle","debug");
41 | System.setProperty("org.slf4j.simpleLogger.log.dev.snowdrop.buildpack.lifecycle.phases","debug");
42 |
43 | String debugScript = "#!/bin/bash\n" +
44 | "echo \"DEBUG INFO\"\n" +
45 | "echo \"Root Perms\"\n" +
46 | "stat -c \"%A $a %u %g %n\" /*\n" +
47 | "echo \"Layer dir Content\"\n" +
48 | "ls -lar /layers\n" +
49 | "echo \"Workspace dir Content\"\n" +
50 | "ls -lar /workspace\n" +
51 | "echo \"Analyzed toml\"\n" +
52 | "cat /layers/analyzed.toml\n" +
53 | "echo \"Run toml\"\n" +
54 | "cat /cnb/run.toml\n" +
55 | "echo \"Stack toml\"\n" +
56 | "cat /cnb/stack.toml\n" +
57 | "echo \"DEBUG END\"\n" +
58 | "LC=$1\n" +
59 | "shift\n" +
60 | "$LC \"$@\"";
61 |
62 | String projectPath = Optional.ofNullable(System.getenv("PROJECT_PATH")).orElse(".");
63 | String JDK = Optional.ofNullable(System.getenv("JDK")).orElse("17");
64 | String builderImage = Optional.ofNullable(System.getenv("BUILDER_IMAGE")).orElse("quay.io/ozzydweller/testbuilders:debug-exporter");
65 | String outputImage = Optional.ofNullable(System.getenv("OUTPUT_IMAGE")).orElse("snowdrop/hello-quarkus:jvm"+JDK);
66 |
67 | System.out.println("RunTest Building path '"+projectPath+"' using '"+builderImage+"' requesting jdk '"+JDK+"'");
68 |
69 | Map envMap = new HashMap<>();
70 | envMap.put("BP_JVM_VERSION",JDK);
71 |
72 | int exitCode = 0;
73 |
74 | OperatingSytem os = OperatingSytem.getOperationSystem();
75 | if(os != OperatingSytem.WIN) {
76 | exitCode = BuildConfig.builder()
77 | .withBuilderImage(new ImageReference(builderImage))
78 | .withOutputImage(new ImageReference(outputImage))
79 | .withNewPlatformConfig()
80 | .withEnvironment(envMap)
81 | //.withPlatformLevel("0.12")
82 | //.withPhaseDebugScript(debugScript)
83 | .and()
84 | .withNewLogConfig()
85 | .withLogger(new SystemLogger())
86 | //.withLogLevel("debug")
87 | .and()
88 | .addNewFileContentApplication(new File(projectPath))
89 | .build()
90 | .getExitCode();
91 | }else{
92 | //github windows runner cannot run linux docker containers,
93 | //so we'll just test the ability for the library to correctly talk
94 | //to the docker daemon.
95 | DockerClient dc = DockerClientUtils.getDockerClient();
96 | try{
97 | dc.pingCmd().exec();
98 | }catch(Exception e){
99 | throw new RuntimeException("Unable to verify docker settings", e);
100 | }
101 | }
102 |
103 | System.exit(exitCode);
104 | }
105 | }
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/.dockerignore:
--------------------------------------------------------------------------------
1 | *
2 | !target/*-runner
3 | !target/*-runner.jar
4 | !target/lib/*
5 | !target/quarkus-app/*
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/.gitignore:
--------------------------------------------------------------------------------
1 | #Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | release.properties
7 | .flattened-pom.xml
8 |
9 | # Eclipse
10 | .project
11 | .classpath
12 | .settings/
13 | bin/
14 |
15 | # IntelliJ
16 | .idea
17 | *.ipr
18 | *.iml
19 | *.iws
20 |
21 | # NetBeans
22 | nb-configuration.xml
23 |
24 | # Visual Studio Code
25 | .vscode
26 | .factorypath
27 |
28 | # OSX
29 | .DS_Store
30 |
31 | # Vim
32 | *.swp
33 | *.swo
34 |
35 | # patch
36 | *.orig
37 | *.rej
38 |
39 | # Local environment
40 | .env
41 |
42 | # Plugin directory
43 | /.quarkus/cli/plugins/
44 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/.mvn/wrapper/.gitignore:
--------------------------------------------------------------------------------
1 | maven-wrapper.jar
2 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 |
20 | import java.io.IOException;
21 | import java.io.InputStream;
22 | import java.net.Authenticator;
23 | import java.net.PasswordAuthentication;
24 | import java.net.URL;
25 | import java.nio.file.Files;
26 | import java.nio.file.Path;
27 | import java.nio.file.Paths;
28 | import java.nio.file.StandardCopyOption;
29 |
30 | public final class MavenWrapperDownloader
31 | {
32 | private static final String WRAPPER_VERSION = "3.2.0";
33 |
34 | private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );
35 |
36 | public static void main( String[] args )
37 | {
38 | log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );
39 |
40 | if ( args.length != 2 )
41 | {
42 | System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
43 | System.exit( 1 );
44 | }
45 |
46 | try
47 | {
48 | log( " - Downloader started" );
49 | final URL wrapperUrl = new URL( args[0] );
50 | final String jarPath = args[1].replace( "..", "" ); // Sanitize path
51 | final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
52 | downloadFileFromURL( wrapperUrl, wrapperJarPath );
53 | log( "Done" );
54 | }
55 | catch ( IOException e )
56 | {
57 | System.err.println( "- Error downloading: " + e.getMessage() );
58 | if ( VERBOSE )
59 | {
60 | e.printStackTrace();
61 | }
62 | System.exit( 1 );
63 | }
64 | }
65 |
66 | private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
67 | throws IOException
68 | {
69 | log( " - Downloading to: " + wrapperJarPath );
70 | if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
71 | {
72 | final String username = System.getenv( "MVNW_USERNAME" );
73 | final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
74 | Authenticator.setDefault( new Authenticator()
75 | {
76 | @Override
77 | protected PasswordAuthentication getPasswordAuthentication()
78 | {
79 | return new PasswordAuthentication( username, password );
80 | }
81 | } );
82 | }
83 | try ( InputStream inStream = wrapperUrl.openStream() )
84 | {
85 | Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
86 | }
87 | log( " - Downloader complete" );
88 | }
89 |
90 | private static void log( String msg )
91 | {
92 | if ( VERBOSE )
93 | {
94 | System.out.println( msg );
95 | }
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
19 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/README.md:
--------------------------------------------------------------------------------
1 | # quarkus-hello
2 |
3 | This project uses Quarkus, the Supersonic Subatomic Java Framework.
4 |
5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6 |
7 | ## Running the application in dev mode
8 |
9 | You can run your application in dev mode that enables live coding using:
10 | ```shell script
11 | ./mvnw compile quarkus:dev
12 | ```
13 |
14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
15 |
16 | ## Packaging and running the application
17 |
18 | The application can be packaged using:
19 | ```shell script
20 | ./mvnw package
21 | ```
22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
24 |
25 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
26 |
27 | If you want to build an _über-jar_, execute the following command:
28 | ```shell script
29 | ./mvnw package -Dquarkus.package.type=uber-jar
30 | ```
31 |
32 | The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`.
33 |
34 | ## Creating a native executable
35 |
36 | You can create a native executable using:
37 | ```shell script
38 | ./mvnw package -Dnative
39 | ```
40 |
41 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
42 | ```shell script
43 | ./mvnw package -Dnative -Dquarkus.native.container-build=true
44 | ```
45 |
46 | You can then execute your native executable with: `./target/quarkus-hello-1.0-runner`
47 |
48 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.
49 |
50 | ## Related Guides
51 |
52 | - Kubernetes ([guide](https://quarkus.io/guides/kubernetes)): Generate Kubernetes resources from annotations
53 | - RESTEasy Reactive ([guide](https://quarkus.io/guides/resteasy-reactive)): A Jakarta REST implementation utilizing build time processing and Vert.x. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.
54 |
55 | ## Provided Code
56 |
57 | ### RESTEasy Reactive
58 |
59 | Easily start your Reactive RESTful Web Services
60 |
61 | [Related guide section...](https://quarkus.io/guides/getting-started-reactive#reactive-jax-rs-resources)
62 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | dev.snowdrop
6 | quarkus-hello
7 | Snowdrop :: Java Buildpack Client :: Samples :: Hello Quarkus
8 | 1.0
9 |
10 | 3.12.1
11 | UTF-8
12 | UTF-8
13 | quarkus-bom
14 | io.quarkus.platform
15 | 3.8.3
16 | true
17 | 3.2.5
18 |
19 |
20 |
21 |
22 | ${quarkus.platform.group-id}
23 | ${quarkus.platform.artifact-id}
24 | ${quarkus.platform.version}
25 | pom
26 | import
27 |
28 |
29 |
30 |
31 |
32 | io.quarkus
33 | quarkus-kubernetes
34 |
35 |
36 | io.quarkus
37 | quarkus-resteasy-reactive
38 |
39 |
40 | io.quarkus
41 | quarkus-container-image-buildpack
42 |
43 |
44 | io.quarkus
45 | quarkus-arc
46 |
47 |
48 | io.quarkus
49 | quarkus-junit5
50 | test
51 |
52 |
53 | io.rest-assured
54 | rest-assured
55 | test
56 |
57 |
58 |
59 |
60 |
61 | ${quarkus.platform.group-id}
62 | quarkus-maven-plugin
63 | ${quarkus.platform.version}
64 | true
65 |
66 |
67 |
68 | build
69 | generate-code
70 | generate-code-tests
71 |
72 |
73 |
74 |
75 |
76 | maven-compiler-plugin
77 | ${compiler-plugin.version}
78 |
79 |
80 | -parameters
81 |
82 |
83 |
84 |
85 | maven-surefire-plugin
86 | ${surefire-plugin.version}
87 |
88 |
89 | org.jboss.logmanager.LogManager
90 | ${maven.home}
91 |
92 |
93 |
94 |
95 | maven-failsafe-plugin
96 | ${surefire-plugin.version}
97 |
98 |
99 |
100 | integration-test
101 | verify
102 |
103 |
104 |
105 |
106 |
107 | ${project.build.directory}/${project.build.finalName}-runner
108 | org.jboss.logmanager.LogManager
109 | ${maven.home}
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 | native
118 |
119 |
120 | native
121 |
122 |
123 |
124 | false
125 | native
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/docker/Dockerfile.jvm:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-hello-jvm .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-jvm
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18 | # Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19 | # when running the container
20 | #
21 | # Then run the container using :
22 | #
23 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-jvm
24 | #
25 | # This image uses the `run-java.sh` script to run the application.
26 | # This scripts computes the command line to execute your Java application, and
27 | # includes memory/GC tuning.
28 | # You can configure the behavior using the following environment properties:
29 | # - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30 | # - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31 | # in JAVA_OPTS (example: "-Dsome.property=foo")
32 | # - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33 | # used to calculate a default maximal heap memory based on a containers restriction.
34 | # If used in a container without any memory constraints for the container then this
35 | # option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36 | # of the container available memory as set here. The default is `50` which means 50%
37 | # of the available memory is used as an upper boundary. You can skip this mechanism by
38 | # setting this value to `0` in which case no `-Xmx` option is added.
39 | # - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40 | # is used to calculate a default initial heap memory based on the maximum heap memory.
41 | # If used in a container without any memory constraints for the container then this
42 | # option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43 | # of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44 | # is used as the initial heap size. You can skip this mechanism by setting this value
45 | # to `0` in which case no `-Xms` option is added (example: "25")
46 | # - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47 | # This is used to calculate the maximum value of the initial heap memory. If used in
48 | # a container without any memory constraints for the container then this option has
49 | # no effect. If there is a memory constraint then `-Xms` is limited to the value set
50 | # here. The default is 4096MB which means the calculated value of `-Xms` never will
51 | # be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52 | # - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53 | # when things are happening. This option, if set to true, will set
54 | # `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55 | # - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56 | # true").
57 | # - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58 | # - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59 | # https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60 | # - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61 | # - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62 | # (example: "20")
63 | # - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64 | # (example: "40")
65 | # - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66 | # (example: "4")
67 | # - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68 | # previous GC times. (example: "90")
69 | # - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70 | # - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71 | # - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72 | # contain the necessary JRE command-line options to specify the required GC, which
73 | # will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74 | # - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
75 | # - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
76 | # - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77 | # accessed directly. (example: "foo.example.com,bar.example.com")
78 | #
79 | ###
80 | FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
81 |
82 | ENV LANGUAGE='en_US:en'
83 |
84 |
85 | # We make four distinct layers so if there are application changes the library layers can be re-used
86 | COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
87 | COPY --chown=185 target/quarkus-app/*.jar /deployments/
88 | COPY --chown=185 target/quarkus-app/app/ /deployments/app/
89 | COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
90 |
91 | EXPOSE 8080
92 | USER 185
93 | ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
94 | ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
95 |
96 | ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
97 |
98 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/docker/Dockerfile.legacy-jar:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dquarkus.package.type=legacy-jar
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/quarkus-hello-legacy-jar .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-legacy-jar
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
18 | # Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005
19 | # when running the container
20 | #
21 | # Then run the container using :
22 | #
23 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello-legacy-jar
24 | #
25 | # This image uses the `run-java.sh` script to run the application.
26 | # This scripts computes the command line to execute your Java application, and
27 | # includes memory/GC tuning.
28 | # You can configure the behavior using the following environment properties:
29 | # - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class")
30 | # - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options
31 | # in JAVA_OPTS (example: "-Dsome.property=foo")
32 | # - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is
33 | # used to calculate a default maximal heap memory based on a containers restriction.
34 | # If used in a container without any memory constraints for the container then this
35 | # option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio
36 | # of the container available memory as set here. The default is `50` which means 50%
37 | # of the available memory is used as an upper boundary. You can skip this mechanism by
38 | # setting this value to `0` in which case no `-Xmx` option is added.
39 | # - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This
40 | # is used to calculate a default initial heap memory based on the maximum heap memory.
41 | # If used in a container without any memory constraints for the container then this
42 | # option has no effect. If there is a memory constraint then `-Xms` is set to a ratio
43 | # of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx`
44 | # is used as the initial heap size. You can skip this mechanism by setting this value
45 | # to `0` in which case no `-Xms` option is added (example: "25")
46 | # - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS.
47 | # This is used to calculate the maximum value of the initial heap memory. If used in
48 | # a container without any memory constraints for the container then this option has
49 | # no effect. If there is a memory constraint then `-Xms` is limited to the value set
50 | # here. The default is 4096MB which means the calculated value of `-Xms` never will
51 | # be greater than 4096MB. The value of this variable is expressed in MB (example: "4096")
52 | # - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output
53 | # when things are happening. This option, if set to true, will set
54 | # `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true").
55 | # - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example:
56 | # true").
57 | # - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787").
58 | # - CONTAINER_CORE_LIMIT: A calculated core limit as described in
59 | # https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2")
60 | # - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024").
61 | # - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion.
62 | # (example: "20")
63 | # - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking.
64 | # (example: "40")
65 | # - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection.
66 | # (example: "4")
67 | # - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus
68 | # previous GC times. (example: "90")
69 | # - GC_METASPACE_SIZE: The initial metaspace size. (example: "20")
70 | # - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100")
71 | # - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should
72 | # contain the necessary JRE command-line options to specify the required GC, which
73 | # will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC).
74 | # - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080")
75 | # - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080")
76 | # - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be
77 | # accessed directly. (example: "foo.example.com,bar.example.com")
78 | #
79 | ###
80 | FROM registry.access.redhat.com/ubi8/openjdk-17:1.18
81 |
82 | ENV LANGUAGE='en_US:en'
83 |
84 |
85 | COPY target/lib/* /deployments/lib/
86 | COPY target/*-runner.jar /deployments/quarkus-run.jar
87 |
88 | EXPOSE 8080
89 | USER 185
90 | ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
91 | ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
92 |
93 | ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
94 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/docker/Dockerfile.native:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-hello .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello
15 | #
16 | ###
17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.9
18 | WORKDIR /work/
19 | RUN chown 1001 /work \
20 | && chmod "g+rwX" /work \
21 | && chown 1001:root /work
22 | COPY --chown=1001:root target/*-runner /work/application
23 |
24 | EXPOSE 8080
25 | USER 1001
26 |
27 | ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
28 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/docker/Dockerfile.native-micro:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
3 | # It uses a micro base image, tuned for Quarkus native executables.
4 | # It reduces the size of the resulting container image.
5 | # Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
6 | #
7 | # Before building the container image run:
8 | #
9 | # ./mvnw package -Dnative
10 | #
11 | # Then, build the image with:
12 | #
13 | # docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/quarkus-hello .
14 | #
15 | # Then run the container using:
16 | #
17 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-hello
18 | #
19 | ###
20 | FROM quay.io/quarkus/quarkus-micro-image:2.0
21 | WORKDIR /work/
22 | RUN chown 1001 /work \
23 | && chmod "g+rwX" /work \
24 | && chown 1001:root /work
25 | COPY --chown=1001:root target/*-runner /work/application
26 |
27 | EXPOSE 8080
28 | USER 1001
29 |
30 | ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
31 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/java/dev/snowdrop/GreetingResource.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import jakarta.ws.rs.GET;
4 | import jakarta.ws.rs.Path;
5 | import jakarta.ws.rs.Produces;
6 | import jakarta.ws.rs.core.MediaType;
7 |
8 | @Path("/hello")
9 | public class GreetingResource {
10 |
11 | @GET
12 | @Produces(MediaType.TEXT_PLAIN)
13 | public String hello() {
14 | return "Hello from RESTEasy Reactive";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/snowdrop/java-buildpack-client/38fc7150e74795017d2333a915602e7a2f4b19b2/samples/testcases/hello-quarkus/src/main/resources/application.properties
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/test/java/dev/snowdrop/GreetingResourceIT.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import io.quarkus.test.junit.QuarkusIntegrationTest;
4 |
5 | @QuarkusIntegrationTest
6 | class GreetingResourceIT extends GreetingResourceTest {
7 | // Execute the same tests but in packaged mode.
8 | }
9 |
--------------------------------------------------------------------------------
/samples/testcases/hello-quarkus/src/test/java/dev/snowdrop/GreetingResourceTest.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop;
2 |
3 | import io.quarkus.test.junit.QuarkusTest;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import static io.restassured.RestAssured.given;
7 | import static org.hamcrest.CoreMatchers.is;
8 |
9 | @QuarkusTest
10 | class GreetingResourceTest {
11 | @Test
12 | void testHelloEndpoint() {
13 | given()
14 | .when().get("/hello")
15 | .then()
16 | .statusCode(200)
17 | .body(is("Hello from RESTEasy Reactive"));
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/snowdrop/java-buildpack-client/38fc7150e74795017d2333a915602e7a2f4b19b2/samples/testcases/hello-spring/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.6.1
9 |
10 |
11 | dev.snowdrop
12 | hello-spring
13 | 0.0.3-SNAPSHOT
14 | Snowdrop :: Java Buildpack Client :: Samples :: Hello Spring
15 | Demo project for Spring Boot with Java Buildpack client script
16 |
17 | 11
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter
23 |
24 |
25 |
26 | org.springframework.boot
27 | spring-boot-starter-test
28 | test
29 |
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-maven-plugin
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/src/main/java/dev/snowdrop/hellospring/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package dev.snowdrop.hellospring;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/samples/testcases/hello-spring/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------