-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add skip parameter to base plugin configuration #911
Conversation
- can use system property -Djib.skip=true to skip if part of lifecycle - still requires "required parameters" on jib to be configured even if skipping, since maven doesn't provide a api for actual goal skipping
If anyone has any decent testing strategies for this, let me know. It's kind of hard to do since maven doesn't actually define "skipping" a goal like gradle does. |
You could run something like the |
@briandealwis I was hoping to ensure that the return was called, maybe I can ensure the log has no more writes after that? |
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.
It would be nice to centralize this duplicate code.
verifier.setSystemProperty("jib.skip", "true"); | ||
|
||
verifier.executeGoal("jib:" + BuildDockerMojo.GOAL_NAME); | ||
File logFile = new File(verifier.getBasedir(), verifier.getLogFileName()); |
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.
nit: use Path
? And new String(Files.readAllBytes(logFile), StandardCharsets.UTF_8)
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.
Yeah, that way, it will remove the Guava dependency.
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.
It's a test class, and we use Guava everywhere!
If I had a concern about this code, it would be with the line endings. You could consider using java.nio.file.Files#readAllLines()
, which also handles multiple line endings and then compare the last three lines.
|
||
verifier.executeGoal("jib:" + BuildDockerMojo.GOAL_NAME); | ||
File logFile = new File(verifier.getBasedir(), verifier.getLogFileName()); | ||
Assert.assertTrue( |
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.
Assert.assertThat(string, CoreMatchers.containsString())
|
||
Path logFile = Paths.get(verifier.getBasedir(), verifier.getLogFileName()); | ||
Assert.assertThat( | ||
new String(Files.readAllBytes(logFile), Charset.forName("UTF-8")), |
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.
StandardCharsets.UTF_8
import org.hamcrest.CoreMatchers; | ||
import org.junit.Assert; | ||
|
||
public class SkippedGoalVerifier { |
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.
short javadoc
|
||
public class SkippedGoalVerifier { | ||
|
||
public static void verifyGoalIsSkipped(TestProject testProject, String goal) |
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.
visibility can all be package-private?
jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/SkippedGoalVerifier.java
Outdated
Show resolved
Hide resolved
String targetImage = "neverbuilt:maven" + System.nanoTime(); | ||
|
||
Verifier verifier = new Verifier(testProject.getProjectRoot().toString()); | ||
verifier.setSystemProperty("_TARGET_IMAGE", targetImage); |
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.
I think we can just remove this line?
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.
without target image specified, it will fail? oh I see, yeah lemme look.
jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/SkippedGoalVerifier.java
Show resolved
Hide resolved
/** A simple verifier utility to test goal skipping accross all our jib goals. */ | ||
class SkippedGoalVerifier { | ||
|
||
private SkippedGoalVerifier() {} |
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.
nit: non-static below static
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.
oh right
/** Verify that a jib goal is skipped */ | ||
static void verifyGoalIsSkipped(TestProject testProject, String goal) | ||
throws VerificationException, IOException { | ||
|
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.
extra newline?
@@ -0,0 +1,51 @@ | |||
/* | |||
* Copyright 2018 Google LLC. All rights reserved. |
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.
I meant to ask about this All rights reserved. It's not normally seen on ASL headers, and @elharo indicated that there was some internal discussion about whether to include it or not.
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.
Okay, yeah I just looked at the updating docs, and All rights reserved
is gone. I'll update that, and then push a larger update across the codebase.
lifecycle
even if skipping, since maven doesn't provide a api for actual
goal skipping
fixes #865