-
Notifications
You must be signed in to change notification settings - Fork 35
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
Export classpath and mainClass as environment variables. #82
Export classpath and mainClass as environment variables. #82
Conversation
This comment has been minimized.
This comment has been minimized.
ccca7b4
to
c4b634c
Compare
@googlebot I signed it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the awesome contribution! This is indeed what many people have asked for multiple times and what we really wanted to do eventually. This will be super useful!
And this extension can be expanded in the future so that not only it sets the environment variables but it directly substitutes these values for some keywords in an entrypoint.
<pluginExtensions>
<pluginExtension>
<implementation>com.google.cloud.tools.jib.maven.extension.classpathmainclass.JibClasspathMainClassExtension</implementation>
<configuration implementation="com.google.cloud.tools.jib.maven.extension.classpathmainclass.Configuration">
<!-- extension configuration -->
<entrypoint>java,-cp,JIB_JAVA_CLASSPATH:/my/classpath,-Dmy.prop=value,JIB_JAVA_MAIN_CLASS</entrypoint>
</configuration>
</pluginExtension>
</pluginExtensions>
But that's another idea going forward, and I think this extension is already very useful!
...47/src/main/java/com/google/cloud/tools/jib/extension/e3147/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
...47/src/main/java/com/google/cloud/tools/jib/extension/e3147/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
...47/src/main/java/com/google/cloud/tools/jib/extension/e3147/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
...47/src/main/java/com/google/cloud/tools/jib/extension/e3147/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
And you can do |
c4b634c
to
3452e55
Compare
@thomasmey just checking in, will you keep working on this? |
Hi, Yes, will do so. I want to add some unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
...main/java/com/google/cloud/tools/jib/common/extension/e3147/ClasspathMainClassExtractor.java
Outdated
Show resolved
Hide resolved
...main/java/com/google/cloud/tools/jib/gradle/extension/e3147/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
...main/java/com/google/cloud/tools/jib/common/extension/e3147/ClasspathMainClassExtractor.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
dependencies { | ||
compileOnly "com.google.code.findbugs:jsr305:3.0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't have a common project. The Maven and Gradle extensions will be published as separate JARs, so unless we publish the common project as another separate JAR, having a common package will result in split packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is, we should duplicate the code in Maven and Gradle, and that's fine.
3452e55
to
719f78b
Compare
Hi, another update. now with tests! 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good!
You will be able to see that ./gradlew build
is failing on GitHub Actions unit tests. I think it can be fixed by copying necessary things from a build.gradle
file in other first-party extensions.
.../google/cloud/tools/jib/gradle/extension/classpathmainclass/ClasspathMainClassExtractor.java
Outdated
Show resolved
Hide resolved
.../google/cloud/tools/jib/gradle/extension/classpathmainclass/ClasspathMainClassExtractor.java
Outdated
Show resolved
Hide resolved
.../google/cloud/tools/jib/gradle/extension/classpathmainclass/ClasspathMainClassExtractor.java
Outdated
Show resolved
Hide resolved
...m/google/cloud/tools/jib/maven/extension/classpathmainclass/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
...urces/META-INF/services/com.google.cloud.tools.jib.gradle.extension.JibGradlePluginExtension
Outdated
Show resolved
Hide resolved
...m/google/cloud/tools/jib/maven/extension/classpathmainclass/ClasspathMainClassExtension.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
719f78b
to
0ebde75
Compare
Codecov Report
@@ Coverage Diff @@
## master #82 +/- ##
============================================
- Coverage 84.87% 82.98% -1.89%
- Complexity 152 160 +8
============================================
Files 14 18 +4
Lines 628 676 +48
Branches 73 81 +8
============================================
+ Hits 533 561 +28
- Misses 83 93 +10
- Partials 12 22 +10
Continue to review full report at Codecov.
|
Jib automatically determines the main class and sets the image' entrypoint accordingly. This extension exports these values also as environment variables in the created image, so a custom entrypoint script can do some processing and then jump into java with: java -cp ${JIB_JAVA_CLASSPATH} ${JIB_JAVA_MAIN_CLASS} See also issue GoogleContainerTools/jib#3147
0ebde75
to
9b4aba4
Compare
This comment has been minimized.
This comment has been minimized.
please have a look again, look good to me now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. There are a few things to fix, but given the delay, I'll take care of it after merging this.
Thank you very much for this great contribution! It'll be very useful to many people.
Jib automatically determines the main class and sets the image'
entrypoint accordingly.
This extension exports these values also as environment variables
in the created image, so a custom entrypoint script can do some processing
and then jump into java with:
java -cp ${JIB_JAVA_CLASSPATH} ${JIB_JAVA_MAIN_CLASS}
See also issue GoogleContainerTools/jib#3147