elharo commented on a change in pull request #347: URL: https://github.com/apache/maven/pull/347#discussion_r628941032
########## File path: maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java ########## @@ -482,6 +500,56 @@ else if ( !parentIds.add( parentData.getId() ) ) return resultModel; } + private Map<String, Activation> getInterpolatedActivations( Model rawModel, + DefaultProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + Map<String, Activation> interpolatedActivations = getProfileActivations( rawModel, true ); + for ( Activation activation : interpolatedActivations.values() ) + { + if ( activation.getFile() != null ) + { + replaceWithInterpolatedValue( activation.getFile(), context, problems ); + } + } + return interpolatedActivations; + } + + private void replaceWithInterpolatedValue( ActivationFile activationFile, ProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + String path = null; + boolean missing = false; + try + { + if ( isNotEmpty( activationFile.getExists() ) ) + { + path = activationFile.getExists(); + missing = false; + String absolutePath = profileActivationFilePathInterpolator.interpolate( path, context ); + activationFile.setExists( absolutePath ); + } + else if ( isNotEmpty( activationFile.getMissing() ) ) + { + path = activationFile.getMissing(); + missing = true; + String absolutePath = profileActivationFilePathInterpolator.interpolate( path, context ); + activationFile.setMissing( absolutePath ); + } + } + catch ( InterpolationException e ) + { + problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ).setMessage( + "Failed to interpolate file location " + path + ": " + e.getMessage() ).setLocation( + activationFile.getLocation( missing ? "missing" : "exists" ) ).setException( e ) ); Review comment: Is it possible to eliminate the missing boolean completely by instead checking whether activationFile.getMissing or activationFile.getExists is null? ########## File path: maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java ########## @@ -482,6 +500,56 @@ else if ( !parentIds.add( parentData.getId() ) ) return resultModel; } + private Map<String, Activation> getInterpolatedActivations( Model rawModel, + DefaultProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + Map<String, Activation> interpolatedActivations = getProfileActivations( rawModel, true ); + for ( Activation activation : interpolatedActivations.values() ) + { + if ( activation.getFile() != null ) + { + replaceWithInterpolatedValue( activation.getFile(), context, problems ); + } + } + return interpolatedActivations; + } + + private void replaceWithInterpolatedValue( ActivationFile activationFile, ProfileActivationContext context, + DefaultModelProblemCollector problems ) + { + String path = null; Review comment: This can be pushed down into each branch of the if-else. No need to declare it here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org