Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build basic hello-world example #85

Closed
sgammon opened this issue Feb 12, 2018 · 7 comments
Closed

Can't build basic hello-world example #85

sgammon opened this issue Feb 12, 2018 · 7 comments
Milestone

Comments

@sgammon
Copy link

sgammon commented Feb 12, 2018

Description of the issue:
Jib tells me the "source files for [the] application layer cannot be empty." But I have a main class and it has content.

Expected behavior:
It should build an image that dutifully echoes a hello world.

Steps to reproduce:

  1. Create new, blank Maven project from IntelliJ
  2. Add Guava so we have some dependencies
  3. Add Jib to your Maven config
  4. Write a minimal Java class that echoes something
  5. Run mvn clean package jib:build

Environment:
Maven:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.3", arch: "x86_64", family: "mac"

IntelliJ:

IntelliJ IDEA 2018.1 EAP (Ultimate Edition)
Build #IU-181.3494.3, built on February 6, 2018
IntelliJ IDEA EAP User
Expiration date: March 8, 2018
JRE: 1.8.0_152-release-1136-b5 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.3

jib-maven-plugin Configuration:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.sample</groupId>
    <artifactId>java-sample</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <app.version>v1</app.version>
        <app.project>some-project/app.project>
        <app.repository>java-sample</app.repository>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>24.0-jre</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>0.1.0</version>
                <configuration>
                    <registry>us.gcr.io</registry>
                    <repository>${app.project}/${app.repository}</repository>
                    <jvmFlags>
                        <jvmFlag>-Xms512m</jvmFlag>
                    </jvmFlags>
                    <mainClass>com.sample.Tool</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Sample main class:

package com.sample;

/**
 * Sample runner.
 */
public final class Tool {
  public static void main(String[] args) {
    System.out.println("Would do container stuff now.");
  }
}

Log output:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building java-sample 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ platform ---
[INFO] Deleting /<redacted>/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ platform ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ platform ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /<redacted>/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ platform ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /<redacted>/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ platform ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ platform ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ platform ---
[INFO] Building jar: /<redacted>/target/java-sample-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- jib-maven-plugin:0.1.0:build (default-cli) @ platform ---
[INFO] 
[INFO] Containerizing application with the following files:
[INFO] 
[INFO] 	Dependencies:
[INFO] 
[INFO] 		/<redacted>/.m2/repository/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar
[INFO] 		/<redacted>/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.3/error_prone_annotations-2.1.3.jar
[INFO] 		/<redacted>/.m2/repository/com/google/guava/guava/24.0-jre/guava-24.0-jre.jar
[INFO] 		/<redacted>/.m2/repository/com/google/j2objc/j2objc-annotations/1.1/j2objc-annotations-1.1.jar
[INFO] 		/<redacted>/.m2/repository/org/checkerframework/checker-compat-qual/2.0.0/checker-compat-qual-2.0.0.jar
[INFO] 		/<redacted>/.m2/repository/org/codehaus/mojo/animal-sniffer-annotations/1.14/animal-sniffer-annotations-1.14.jar
[INFO] 	Resources:
[INFO] 
[INFO] 	Classes:
[INFO] 
[INFO] 		/<redacted>/target/classes/com
[INFO] 
[INFO] 
[INFO] Pushing image as us.gcr.io/<project>/java-sample:latest
[INFO] 
[INFO] RUNNING	Building and pushing image
[INFO] RUNNING	Authenticating with base image registry
[INFO] RUNNING	Authenticating with us.gcr.io using docker-credential-null
[INFO] Authenticating with us.gcr.io using docker-credential-null : 0.07 ms
[INFO] RUNNING	Building application layers
[INFO] RUNNING	Building dependencies layer
[INFO] RUNNING	Building resources layer
[INFO] Building application layers : 3.126 ms
[INFO] RUNNING	Building classes layer
[INFO] RUNNING	Setting up to push layers
[INFO] Setting up to push layers : 2.143 ms
[INFO] Building resources layer : 43.861 ms
[INFO] Building classes layer : 45.293 ms
[INFO] RUNNING	Pushing BLOB sha256:fe5c85e3330d1512c783e0caa2ae1efe2146847afe9a87b157a64f84b2ea7590
[INFO] Building dependencies layer : 342.431 ms
[INFO] RUNNING	Pushing BLOB sha256:e7be02943e29ba3a38d4fb0b7edd3ad5079f41ab0af3f417c08907539b2ee701
[INFO] Pushing BLOB sha256:e7be02943e29ba3a38d4fb0b7edd3ad5079f41ab0af3f417c08907539b2ee701 : 923.678 ms
[INFO] Pushing BLOB sha256:fe5c85e3330d1512c783e0caa2ae1efe2146847afe9a87b157a64f84b2ea7590 : 1266.138 ms
[INFO] Authenticating with base image registry : 1398.364 ms
[INFO] RUNNING	Pulling base image manifest
[INFO] Pulling base image manifest : 840.153 ms
[INFO] RUNNING	Setting up base image caching
[INFO] RUNNING	Pulling base image layer sha256:69e0471bd59644ac9a3820d2ff305b15b1783f7af0c2654b4c7fb0b5df91823a
[INFO] RUNNING	Pulling base image layer sha256:bb8371eaf7266a8e470788b8c2c4f33ff2c466bf31ecffbb2ca1ecf2657cd10a
[INFO] Setting up base image caching : 2.982 ms
[INFO] RUNNING	Pulling base image layer sha256:a79ed59a6f9f53ce631200429907b31aee38484f24589be8b65fe66a583a51c2
[INFO] RUNNING	Setting up to push layers
[INFO] Setting up to push layers : 0.155 ms
[INFO] Pulling base image layer sha256:a79ed59a6f9f53ce631200429907b31aee38484f24589be8b65fe66a583a51c2 : 429.458 ms
[INFO] RUNNING	Pushing BLOB sha256:a79ed59a6f9f53ce631200429907b31aee38484f24589be8b65fe66a583a51c2
[INFO] Pushing BLOB sha256:a79ed59a6f9f53ce631200429907b31aee38484f24589be8b65fe66a583a51c2 : 519.656 ms
[INFO] Pulling base image layer sha256:bb8371eaf7266a8e470788b8c2c4f33ff2c466bf31ecffbb2ca1ecf2657cd10a : 1387.601 ms
[INFO] RUNNING	Pushing BLOB sha256:bb8371eaf7266a8e470788b8c2c4f33ff2c466bf31ecffbb2ca1ecf2657cd10a
[INFO] Pushing BLOB sha256:bb8371eaf7266a8e470788b8c2c4f33ff2c466bf31ecffbb2ca1ecf2657cd10a : 644.379 ms
[INFO] Pulling base image layer sha256:69e0471bd59644ac9a3820d2ff305b15b1783f7af0c2654b4c7fb0b5df91823a : 4992.586 ms
[INFO] RUNNING	Pushing BLOB sha256:69e0471bd59644ac9a3820d2ff305b15b1783f7af0c2654b4c7fb0b5df91823a
[INFO] Pushing BLOB sha256:69e0471bd59644ac9a3820d2ff305b15b1783f7af0c2654b4c7fb0b5df91823a : 418.564 ms
[INFO] RUNNING	Pushing new image
[INFO] Pushing new image : 0.335 ms
[INFO] Building and pushing image : 7706.113 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.860 s
[INFO] Finished at: 2018-02-12T10:26:15-08:00
[INFO] Final Memory: 23M/371M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:0.1.0:build (default-cli) on project platform: Build image failed: Source files for application layer cannot be empty -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Additional Information:

  • gcloud is logged in
  • gcloud config get-value project produces the correct project
@coollog
Copy link
Contributor

coollog commented Feb 12, 2018

Hi @sgammon , thanks for reporting this issue! #72 is a prior issue that described the same error. We have fixed that issue and the fix should be released in v0.1.1 (due to release soon). I will update this issue once that version is released.

@coollog coollog added this to the 0.1.1 milestone Feb 12, 2018
@sgammon
Copy link
Author

sgammon commented Feb 12, 2018

Hey @coollog, thank you for the quick reply. Is there a snapshots repo or some other way I can depend on the new code? I suppose I could always clone and mvn package install with a custom version, but that's lame 😉

@sgammon
Copy link
Author

sgammon commented Feb 12, 2018

this is basically an experimental toy project and i don't mind if the dependency breaks later.

@coollog
Copy link
Contributor

coollog commented Feb 12, 2018

We do not currently release snapshot versions, but we will look into that (thanks for the suggestion!). In the future, we will release new versions more finely so issues like these can be fixed and released more rapidly.

@patflynn
Copy link
Contributor

patflynn commented Feb 12, 2018 via email

@coollog
Copy link
Contributor

coollog commented Feb 12, 2018

Filed #89

@coollog
Copy link
Contributor

coollog commented Feb 13, 2018

@sgammon v0.1.1 has been released with the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants