You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Niels Basjes (Jira)" <ji...@apache.org> on 2023/03/25 23:03:00 UTC

[jira] [Commented] (MSHADE-440) Expanded properties in profiles in DRP

    [ https://issues.apache.org/jira/browse/MSHADE-440?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17705004#comment-17705004 ] 

Niels Basjes commented on MSHADE-440:
-------------------------------------

I spent some time digging and found using this test mojo that the {{project.getOriginalModel()}} which is used as the input for creating the DRP already has this problem.

Does this make this a maven problem instead of this plugin?

{code:java}
@Mojo(
        name = "print",
        defaultPhase = LifecyclePhase.VALIDATE,
        threadSafe = true,
        requiresDependencyResolution = ResolutionScope.RUNTIME)
public class PrintMojo extends AbstractMojo {
    @Parameter(defaultValue = "${project}", readonly = true, required = true)
    private MavenProject project;

    @Override
    public void execute() {
        printModel(project.getOriginalModel(), "Original model");
    }

    public void printModel(Model model, String label) {
        System.out.println("====================================================================");
        System.out.println("==== " + label);
        System.out.println("====================================================================");
        Writer out = new BufferedWriter(new OutputStreamWriter(System.out));
        try {
            PomWriter.write(out, model, true);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        System.out.println("====================================================================");
    }
}
{code}

> Expanded properties in profiles in DRP
> --------------------------------------
>
>                 Key: MSHADE-440
>                 URL: https://issues.apache.org/jira/browse/MSHADE-440
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>            Reporter: Niels Basjes
>            Priority: Major
>
> If you have a profile with the {{{}$\{project.basedir{}}}} in the configuration of a plugin IN that profile.
> Then when you run maven-shade with that profile active the  {{{}$\{project.basedir{}}}}  will be expanded to the full value in some places of the generated DRP.
> If you have something like this in the pom.xml 
> {code:xml}
>   <profiles>
>     <profile>
>       <id>testProfile</id>
>       <properties>
>         <prop>CHECK Inside profile ${project.basedir}.</prop>
>       </properties>
>       <build>
>         <plugins>
>           <plugin>
>             <groupId>org.apache.maven.plugins</groupId>
>             <artifactId>maven-clean-plugin</artifactId>
>             <executions>
>               <execution>
>                 <id>CHECK Inside profile ${project.basedir}.</id>
>                 <configuration>
>                   <testOutputDirectory>CHECK Inside profile ${project.basedir}.</testOutputDirectory>
>                 </configuration>
>               </execution>
>             </executions>
>           </plugin>
>         </plugins>
>       </build>
>     </profile>
>   </profiles>
> {code}
> then the DRP will have the project.basedir value replaced with the actual path.
> This ONLY happens if it is in an profile that was active during while shade was running.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)