@@ -71,17 +71,10 @@ private Class<? extends BuildableManifestTemplate> getManifestTemplateClass() {
7171
7272 @ Override
7373 public void execute () throws MojoExecutionException , MojoFailureException {
74- // These @Nullable parameters should never be null.
75- Preconditions .checkNotNull (project );
76- Preconditions .checkNotNull (session );
77- Preconditions .checkNotNull (to );
78- Preconditions .checkNotNull (to .image );
79- Preconditions .checkNotNull (format );
80-
8174 validateParameters ();
8275
83- ProjectProperties projectProperties = new ProjectProperties (project , getLog ());
84- String inferredMainClass = projectProperties .getMainClass (mainClass );
76+ ProjectProperties projectProperties = new ProjectProperties (getProject () , getLog ());
77+ String inferredMainClass = projectProperties .getMainClass (getMainClass () );
8578
8679 SourceFilesConfiguration sourceFilesConfiguration =
8780 projectProperties .getSourceFilesConfiguration ();
@@ -92,24 +85,24 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9285
9386 // Checks Maven settings for registry credentials.
9487 MavenSettingsServerCredentials mavenSettingsServerCredentials =
95- new MavenSettingsServerCredentials (session .getSettings ());
88+ new MavenSettingsServerCredentials (Preconditions . checkNotNull ( session ) .getSettings ());
9689 RegistryCredentials knownBaseRegistryCredentials =
9790 mavenSettingsServerCredentials .retrieve (baseImage .getRegistry ());
9891 RegistryCredentials knownTargetRegistryCredentials =
9992 mavenSettingsServerCredentials .retrieve (targetImage .getRegistry ());
10093
101- ImageFormat imageFormatToEnum = ImageFormat .valueOf (format );
94+ ImageFormat imageFormatToEnum = ImageFormat .valueOf (getFormat () );
10295 BuildConfiguration buildConfiguration =
10396 BuildConfiguration .builder (new MavenBuildLogger (getLog ()))
10497 .setBaseImage (baseImage )
105- .setBaseImageCredentialHelperName (from == null ? null : from . credHelper )
98+ .setBaseImageCredentialHelperName (getBaseImageCredentialHelperName () )
10699 .setKnownBaseRegistryCredentials (knownBaseRegistryCredentials )
107100 .setTargetImage (targetImage )
108- .setTargetImageCredentialHelperName (to . credHelper )
101+ .setTargetImageCredentialHelperName (getTargetImageCredentialHelperName () )
109102 .setKnownTargetRegistryCredentials (knownTargetRegistryCredentials )
110103 .setMainClass (inferredMainClass )
111- .setJvmFlags (jvmFlags )
112- .setEnvironment (environment )
104+ .setJvmFlags (getJvmFlags () )
105+ .setEnvironment (getEnvironment () )
113106 .setTargetFormat (imageFormatToEnum .getManifestTemplateClass ())
114107 .build ();
115108
@@ -122,11 +115,14 @@ public void execute() throws MojoExecutionException, MojoFailureException {
122115 RegistryClient .setUserAgentSuffix (USER_AGENT_SUFFIX );
123116
124117 // Uses a directory in the Maven build cache as the Jib cache.
125- Path cacheDirectory = Paths .get (project .getBuild ().getDirectory (), CACHE_DIRECTORY_NAME );
118+ Path cacheDirectory = Paths .get (getProject () .getBuild ().getDirectory (), CACHE_DIRECTORY_NAME );
126119 try {
127120 BuildImageStepsRunner buildImageStepsRunner =
128121 BuildImageStepsRunner .newRunner (
129- buildConfiguration , sourceFilesConfiguration , cacheDirectory , useOnlyProjectCache );
122+ buildConfiguration ,
123+ sourceFilesConfiguration ,
124+ cacheDirectory ,
125+ getUseOnlyProjectCache ());
130126
131127 getLog ().info ("" );
132128 getLog ().info ("Pushing image as " + targetImage );
@@ -153,15 +149,15 @@ private void validateParameters() throws MojoFailureException {
153149 // Validates 'imageFormat'.
154150 boolean validFormat = false ;
155151 for (ImageFormat imageFormat : ImageFormat .values ()) {
156- if (imageFormat .name ().equals (format )) {
152+ if (imageFormat .name ().equals (getFormat () )) {
157153 validFormat = true ;
158154 break ;
159155 }
160156 }
161157 if (!validFormat ) {
162158 throw new MojoFailureException (
163159 "<imageFormat> parameter is configured with value '"
164- + format
160+ + getFormat ()
165161 + "', but the only valid configuration options are '"
166162 + ImageFormat .Docker
167163 + "' and '"
@@ -172,11 +168,8 @@ private void validateParameters() throws MojoFailureException {
172168
173169 /** @return the {@link ImageReference} parsed from {@link #from}. */
174170 private ImageReference getBaseImageReference () throws MojoFailureException {
175- Preconditions .checkNotNull (from );
176- Preconditions .checkNotNull (from .image );
177-
178171 try {
179- ImageReference baseImage = ImageReference .parse (from . image );
172+ ImageReference baseImage = ImageReference .parse (getBaseImage () );
180173
181174 if (baseImage .usesDefaultTag ()) {
182175 getLog ()
@@ -195,11 +188,8 @@ private ImageReference getBaseImageReference() throws MojoFailureException {
195188
196189 /** @return the {@link ImageReference} parsed from {@link #to}. */
197190 private ImageReference getTargetImageReference () throws MojoFailureException {
198- Preconditions .checkNotNull (to );
199- Preconditions .checkNotNull (to .image );
200-
201191 try {
202- return ImageReference .parse (to . image );
192+ return ImageReference .parse (getTargetImage () );
203193
204194 } catch (InvalidImageReferenceException ex ) {
205195 throw new MojoFailureException ("Parameter 'to' is invalid" , ex );
0 commit comments