Search in sources :

Example 1 with DirectoryWalker

use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.

the class MainClassFinderTest method testFindMainClass_importedMethods.

@Test
public void testFindMainClass_importedMethods() throws URISyntaxException, IOException {
    Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/imported-methods").toURI());
    MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
    Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
    MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("main.MainClass"));
}
Also used : Path(java.nio.file.Path) Result(com.google.cloud.tools.jib.api.MainClassFinder.Result) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) Test(org.junit.Test)

Example 2 with DirectoryWalker

use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.

the class MainClassFinderTest method testFindMainClass_externalClasses.

@Test
public void testFindMainClass_externalClasses() throws URISyntaxException, IOException {
    Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/external-classes").toURI());
    MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
    Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
    MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("main.MainClass"));
}
Also used : Path(java.nio.file.Path) Result(com.google.cloud.tools.jib.api.MainClassFinder.Result) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) Test(org.junit.Test)

Example 3 with DirectoryWalker

use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.

the class MainClassFinderTest method testFindMainClass_innerClasses.

@Test
public void testFindMainClass_innerClasses() throws URISyntaxException, IOException {
    Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/inner-classes").toURI());
    MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
    Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
    MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("HelloWorld$InnerClass"));
}
Also used : Path(java.nio.file.Path) Result(com.google.cloud.tools.jib.api.MainClassFinder.Result) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) Test(org.junit.Test)

Example 4 with DirectoryWalker

use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.

the class MainClassFinderTest method testMainClass_varargs.

@Test
public void testMainClass_varargs() throws URISyntaxException, IOException {
    Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/varargs").toURI());
    MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
    Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
    MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("HelloWorld"));
}
Also used : Path(java.nio.file.Path) Result(com.google.cloud.tools.jib.api.MainClassFinder.Result) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) Test(org.junit.Test)

Example 5 with DirectoryWalker

use of com.google.cloud.tools.jib.filesystem.DirectoryWalker in project jib by GoogleContainerTools.

the class MainClassFinderTest method testFindMainClass_subdirectories.

@Test
public void testFindMainClass_subdirectories() throws URISyntaxException, IOException {
    Path rootDirectory = Paths.get(Resources.getResource("core/class-finder-tests/subdirectories").toURI());
    MainClassFinder.Result mainClassFinderResult = MainClassFinder.find(new DirectoryWalker(rootDirectory).walk(), logEventConsumer);
    Assert.assertSame(Result.Type.MAIN_CLASS_FOUND, mainClassFinderResult.getType());
    MatcherAssert.assertThat(mainClassFinderResult.getFoundMainClass(), CoreMatchers.containsString("multi.layered.HelloWorld"));
}
Also used : Path(java.nio.file.Path) Result(com.google.cloud.tools.jib.api.MainClassFinder.Result) DirectoryWalker(com.google.cloud.tools.jib.filesystem.DirectoryWalker) Test(org.junit.Test)

Aggregations

DirectoryWalker (com.google.cloud.tools.jib.filesystem.DirectoryWalker)52 Path (java.nio.file.Path)48 Test (org.junit.Test)23 Result (com.google.cloud.tools.jib.api.MainClassFinder.Result)20 AbsoluteUnixPath (com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath)15 IOException (java.io.IOException)11 FileEntriesLayer (com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer)9 Files (java.nio.file.Files)9 FileTime (java.nio.file.attribute.FileTime)8 List (java.util.List)8 Predicate (java.util.function.Predicate)8 Instant (java.time.Instant)7 Map (java.util.Map)7 ModificationTimeProvider (com.google.cloud.tools.jib.api.buildplan.ModificationTimeProvider)6 RelativeUnixPath (com.google.cloud.tools.jib.api.buildplan.RelativeUnixPath)6 InputStream (java.io.InputStream)6 Paths (java.nio.file.Paths)6 ArrayList (java.util.ArrayList)6 StringJoiner (java.util.StringJoiner)6 FilePermissions (com.google.cloud.tools.jib.api.buildplan.FilePermissions)5