Skip to content

Commit

Permalink
Make snapshot dependencies also write to /app/libs
Browse files Browse the repository at this point in the history
  • Loading branch information
loosebazooka committed Jul 12, 2018
1 parent 3fa7cda commit 7f86750
Show file tree
Hide file tree
Showing 13 changed files with 7 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public static ImmutableList<String> makeEntrypoint(
ImmutableList<String> classPaths =
ImmutableList.of(
sourceFilesConfiguration.getDependenciesPathOnImage() + "*",
sourceFilesConfiguration.getSnapshotDependenciesPathOnImage() + "*",
sourceFilesConfiguration.getResourcesPathOnImage(),
sourceFilesConfiguration.getClassesPathOnImage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public interface SourceFilesConfiguration {

String DEFAULT_DEPENDENCIES_PATH_ON_IMAGE = "/app/libs/";
String DEFAULT_SNAPSHOT_DEPENDENCIES_PATH_ON_IMAGE = "/app/snapshot-libs/";
String DEFAULT_RESOURCES_PATH_ON_IMAGE = "/app/resources/";
String DEFAULT_CLASSES_PATH_ON_IMAGE = "/app/classes/";

Expand Down Expand Up @@ -55,16 +54,10 @@ public interface SourceFilesConfiguration {

/**
* @return the Unix-style path where the dependencies source files are placed in the container
* filesystem. Must end with slash.
* filesystem. Must end with slash. This includes both regular and snapshot dependencies.
*/
String getDependenciesPathOnImage();

/**
* @return the Unix-style path where the snapshot dependencies sources files are place in the
* container filesystem. Must end with slash.
*/
String getSnapshotDependenciesPathOnImage();

/**
* @return the Unix-style path where the resources source files are placed in the container
* filesystem. Must end with slash.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static ImmutableList<BuildAndCacheApplicationLayerStep> makeList(
LayerConfiguration.builder()
.addEntry(
sourceFilesConfiguration.getSnapshotDependenciesFiles(),
sourceFilesConfiguration.getSnapshotDependenciesPathOnImage())
sourceFilesConfiguration.getDependenciesPathOnImage())
.build(),
cache))
.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ String makeDockerfile() throws JsonProcessingException {
.append("\n\nCOPY libs ")
.append(sourceFilesConfiguration.getDependenciesPathOnImage())
.append("\nCOPY snapshot-libs ")
.append(sourceFilesConfiguration.getSnapshotDependenciesPathOnImage())
.append(sourceFilesConfiguration.getDependenciesPathOnImage())
.append("\nCOPY resources ")
.append(sourceFilesConfiguration.getResourcesPathOnImage())
.append("\nCOPY classes ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class EntrypointBuilderTest {
@Test
public void testMakeEntrypoint() {
String expectedDependenciesPath = "/app/libs/";
String expectedSnapshotDependenciesPath = "/app/snapshot-libs/";
String expectedResourcesPath = "/app/resources/";
String expectedClassesPath = "/app/classes/";
List<String> expectedJvmFlags = Arrays.asList("-flag", "anotherFlag");
Expand All @@ -39,8 +38,6 @@ public void testMakeEntrypoint() {

Mockito.when(mockSourceFilesConfiguration.getDependenciesPathOnImage())
.thenReturn(expectedDependenciesPath);
Mockito.when(mockSourceFilesConfiguration.getSnapshotDependenciesPathOnImage())
.thenReturn(expectedSnapshotDependenciesPath);
Mockito.when(mockSourceFilesConfiguration.getResourcesPathOnImage())
.thenReturn(expectedResourcesPath);
Mockito.when(mockSourceFilesConfiguration.getClassesPathOnImage())
Expand All @@ -52,7 +49,7 @@ public void testMakeEntrypoint() {
"-flag",
"anotherFlag",
"-cp",
"/app/libs/*:/app/snapshot-libs/*:/app/resources/:/app/classes/",
"/app/libs/*:/app/resources/:/app/classes/",
"SomeMainClass"),
EntrypointBuilder.makeEntrypoint(
mockSourceFilesConfiguration, expectedJvmFlags, expectedMainClass));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ public String getDependenciesPathOnImage() {
return EXTRACTION_PATH + "libs/";
}

@Override
public String getSnapshotDependenciesPathOnImage() {
return EXTRACTION_PATH + "snapshot-libs/";
}

@Override
public String getResourcesPathOnImage() {
return EXTRACTION_PATH + "resources/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void testRun()
ImmutableList.of(
new LayerEntry(
testSourceFilesConfiguration.getSnapshotDependenciesFiles(),
testSourceFilesConfiguration.getSnapshotDependenciesPathOnImage()));
testSourceFilesConfiguration.getDependenciesPathOnImage()));
ImmutableList<LayerEntry> resourcesLayerEntry =
ImmutableList.of(
new LayerEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ private static void assertSameFiles(Path directory1, Path directory2) throws IOE
@Before
public void setUpMocks() {
String expectedDependenciesPath = "/app/libs/";
String expectedSnapshotDependenciesPath = "/app/snapshot-libs/";
String expectedResourcesPath = "/app/resources/";
String expectedClassesPath = "/app/classes/";

Mockito.when(mockSourceFilesConfiguration.getDependenciesPathOnImage())
.thenReturn(expectedDependenciesPath);
Mockito.when(mockSourceFilesConfiguration.getSnapshotDependenciesPathOnImage())
.thenReturn(expectedSnapshotDependenciesPath);
Mockito.when(mockSourceFilesConfiguration.getResourcesPathOnImage())
.thenReturn(expectedResourcesPath);
Mockito.when(mockSourceFilesConfiguration.getClassesPathOnImage())
Expand Down
4 changes: 2 additions & 2 deletions jib-core/src/test/resources/sampleDockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM somebaseimage

COPY libs /app/libs/
COPY snapshot-libs /app/snapshot-libs/
COPY snapshot-libs /app/libs/
COPY resources /app/resources/
COPY classes /app/classes/

EXPOSE 1000/tcp
EXPOSE 2000-2010/udp
ENTRYPOINT ["java","-flag","another\"Flag","-cp","/app/libs/*:/app/snapshot-libs/*:/app/resources/:/app/classes/","SomeMainClass"]
ENTRYPOINT ["java","-flag","another\"Flag","-cp","/app/libs/*:/app/resources/:/app/classes/","SomeMainClass"]
CMD ["arg1","arg2"]
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ public String getDependenciesPathOnImage() {
return DEFAULT_DEPENDENCIES_PATH_ON_IMAGE;
}

@Override
public String getSnapshotDependenciesPathOnImage() {
return DEFAULT_SNAPSHOT_DEPENDENCIES_PATH_ON_IMAGE;
}

@Override
public String getResourcesPathOnImage() {
return DEFAULT_RESOURCES_PATH_ON_IMAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ public void test_noClassesFiles() throws IOException {
public void test_correctPathsOnImage() {
Assert.assertEquals(
"/app/libs/", testGradleSourceFilesConfiguration.getDependenciesPathOnImage());
Assert.assertEquals(
"/app/snapshot-libs/",
testGradleSourceFilesConfiguration.getSnapshotDependenciesPathOnImage());
Assert.assertEquals(
"/app/resources/", testGradleSourceFilesConfiguration.getResourcesPathOnImage());
Assert.assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ public String getDependenciesPathOnImage() {
return DEFAULT_DEPENDENCIES_PATH_ON_IMAGE;
}

@Override
public String getSnapshotDependenciesPathOnImage() {
return DEFAULT_SNAPSHOT_DEPENDENCIES_PATH_ON_IMAGE;
}

@Override
public String getResourcesPathOnImage() {
return DEFAULT_RESOURCES_PATH_ON_IMAGE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ public void test_correctFiles() throws URISyntaxException {
public void test_correctPathsOnImage() {
Assert.assertEquals(
"/app/libs/", testMavenSourceFilesConfiguration.getDependenciesPathOnImage());
Assert.assertEquals(
"/app/snapshot-libs/",
testMavenSourceFilesConfiguration.getSnapshotDependenciesPathOnImage());
Assert.assertEquals(
"/app/resources/", testMavenSourceFilesConfiguration.getResourcesPathOnImage());
Assert.assertEquals("/app/classes/", testMavenSourceFilesConfiguration.getClassesPathOnImage());
Expand Down

0 comments on commit 7f86750

Please sign in to comment.