@@ -273,82 +273,8 @@ public class InstallArtifactMojo extends AbstractCopyJarsMojo {
273273
274274 @ Override
275275 public void execute () throws MojoExecutionException , MojoFailureException {
276- ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator (session , mojoExecution );
277-
278- // Keep backwards compatibility to delete.other.versions
279- try {
280- Object evaluate = evaluator .evaluate ("${" +deleteOtherVersionsProperty +"}" );
281- if (evaluate != null ) {
282- getLog ().warn ("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
283- deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions .older : OtherVersions .never ;
284- }
285- }
286- catch (ExpressionEvaluationException e ) {
287- getLog ().warn (e );
288- }
289-
290- // Keep backwards compatibility to imagej.app.directory
291- try {
292- Object evaluate = evaluator .evaluate ("${" +imagejDirectoryProperty +"}" );
293-
294- // Use imagejDirectory if it is set (directly or via imagej.app.directory)
295- if (imagejDirectory != null ) {
296- if (evaluate == null ) {
297- getLog ().warn ("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead" );
298- } else {
299- getLog ().warn ("Property '" + imagejDirectoryProperty + "' is deprecated. Use '" + appDirectoryProperty +"' instead" );
300- }
301-
302- // TODO How do we want to handle cases where both are provided. Which
303- // property should take precedence?
304- appDirectory = imagejDirectory ;
305- }
306- }
307- catch (ExpressionEvaluationException e ) {
308- getLog ().warn (e );
309- }
310-
311- // Keep backwards compatibility to imagej.app.subdirectory
312- try {
313- Object evaluate = evaluator .evaluate ("${" +imagejSubdirectoryProperty +"}" );
314-
315- // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory)
316- if (imagejSubdirectory != null ) {
317- if (evaluate == null ) {
318- getLog ().warn ("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead" );
319- } else {
320- getLog ().warn ("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '" + appSubdirectoryProperty +"' instead" );
321- }
322-
323- // TODO How do we want to handle cases where both are provided. Which
324- // property should take precedence?
325- appSubdirectory = imagejSubdirectory ;
326- }
327- }
328- catch (ExpressionEvaluationException e ) {
329- getLog ().warn (e );
330- }
331-
332- // Keep backwards compatibility to imagej.deleteOtherVersions
333- try {
334- Object evaluate = evaluator .evaluate ("${" +imagejDeleteOtherVersionsPolicyProperty +"}" );
335-
336- // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions)
337- if (imagejDeleteOtherVersionsPolicy != null ) {
338- if (evaluate == null ) {
339- getLog ().warn ("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead" );
340- } else {
341- getLog ().warn ("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
342- }
343-
344- // TODO How do we want to handle cases where both are provided. Which
345- // property should take precedence?
346- deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy ;
347- }
348- }
349- catch (ExpressionEvaluationException e ) {
350- getLog ().warn (e );
351- }
276+ // Keep backwards compatibility
277+ handleBackwardsCompatibility ();
352278
353279 if (appDirectory == null ) {
354280 throw new MojoExecutionException (
@@ -443,6 +369,64 @@ public boolean accept(Node node, List<Node> parents) {
443369 }
444370 }
445371
372+ /**
373+ * TODO Javadoc
374+ */
375+ private void handleBackwardsCompatibility () {
376+ ExpressionEvaluator evaluator = new PluginParameterExpressionEvaluator (session , mojoExecution );
377+
378+ try {
379+ // If at least one scijava.* property is set, ignore imagej.* properties
380+ if (evaluator .evaluate ("${" + appDirectoryProperty + "}" ) == null &&
381+ evaluator .evaluate ("${" + appSubdirectoryProperty + "}" ) == null &&
382+ evaluator .evaluate ("${" + deleteOtherVersionsPolicyProperty + "}" ) == null )
383+ {
384+
385+ // Keep backwards compatibility to delete.other.versions
386+ if (evaluator .evaluate ("${" +deleteOtherVersionsProperty +"}" ) != null ) {
387+ getLog ().warn ("Property '" + deleteOtherVersionsProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
388+ deleteOtherVersionsPolicy = deleteOtherVersions ? OtherVersions .older : OtherVersions .never ;
389+ }
390+
391+ // Keep backwards compatibility to imagej.app.directory
392+ // Use imagejDirectory if it is set (directly or via imagej.app.directory)
393+ if (imagejDirectory != null ) {
394+ if (evaluator .evaluate ("${" +imagejDirectoryProperty +"}" ) == null ) {
395+ getLog ().warn ("Configuration property 'imagejDirectory' is deprecated. Use 'appDirectory' instead" );
396+ } else {
397+ getLog ().warn ("Property '" + imagejDirectoryProperty + "' is deprecated. Use '" + appDirectoryProperty +"' instead" );
398+ }
399+ appDirectory = imagejDirectory ;
400+ }
401+
402+ // Keep backwards compatibility to imagej.app.subdirectory
403+ // Use imagejSubdirectory if it is set (directly or via imagej.app.subdirectory)
404+ if (imagejSubdirectory != null ) {
405+ if (evaluator .evaluate ("${" +imagejSubdirectoryProperty +"}" ) == null ) {
406+ getLog ().warn ("Configuration property 'imagejSubdirectory' is deprecated. Use 'appSubdirectory' instead" );
407+ } else {
408+ getLog ().warn ("Property '" + imagejSubdirectoryProperty + "' is deprecated. Use '" + appSubdirectoryProperty +"' instead" );
409+ }
410+ appSubdirectory = imagejSubdirectory ;
411+ }
412+
413+ // Keep backwards compatibility to imagej.deleteOtherVersions
414+ // Use imagejDeleteOtherVersionsPolicy if it is set (directly or via imagej.deleteOtherVersions)
415+ if (imagejDeleteOtherVersionsPolicy != null ) {
416+ if (evaluator .evaluate ("${" +imagejDeleteOtherVersionsPolicyProperty +"}" ) == null ) {
417+ getLog ().warn ("Configuration property 'imagejDeleteOtherVersionsPolicy' is deprecated. Use 'deleteOtherVersionsPolicy' instead" );
418+ } else {
419+ getLog ().warn ("Property '" + imagejDeleteOtherVersionsPolicyProperty + "' is deprecated. Use '" + deleteOtherVersionsPolicyProperty +"' instead" );
420+ }
421+ deleteOtherVersionsPolicy = imagejDeleteOtherVersionsPolicy ;
422+ }
423+ }
424+ }
425+ catch (ExpressionEvaluationException e ) {
426+ getLog ().warn (e );
427+ }
428+ }
429+
446430 /**
447431 * Checks if a {@link DependableCoordinate} and an {@link Artifact} share
448432 * the same GAV.
0 commit comments