dehasi commented on a change in pull request #347: URL: https://github.com/apache/maven/pull/347#discussion_r629169604
########## 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: Indeed it's possible. If we're in the `catch` block, it means that we tried to interpolate a file. Which means that one of them definitely exists. That's why I can use the same `isNotEmpty` check, as in the `try` block. -- 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