[ 
https://issues.apache.org/jira/browse/MSHADE-145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17331667#comment-17331667
 ] 
Alexander Kriegisch edited comment on MSHADE-145 at 4/26/21, 1:26 AM:
----------------------------------------------------------------------

Because I want to use 
{{<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>}}
 in my own project and did not notice any issues with it, I became curious, 
trying to reproduce this problem the documentation is still warning about in 
Maven Shade 3.2.4. I wondered if it was an issue with older plugin or Maven 
versions. So I downloaded the sample project attached here and tried to 
reproduce it, running on Java 8 and compiling with Java 8 source/target. 
Findings:
* Maven 3.0.x is no longer working because it wants to download using HTTP, but 
Maven Central needs HTTPS nowadays.
* Next, I tried Maven 3.1.1. Because of [this 
problem|https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound], 
I upgraded to Maven Shade 2.1 and Maven Site 3.3, as recommended.
* The next problem was with site generation because it could not find a class, 
requiring me to specify a version for Project Info Reports (PIP). I chose 2.7, 
which was released about the same time as Site 3.3.
* There again, I had problems with HTTP instead of HTTPS download, this time 
inside Site 3.3, so I upgraded to Maven 3.2.3 which was said to have fixed 
HTTPS-related download problems.
* Finally, I could run `mvn clean install site`, but did not see any issues 
with site generation. Maybe the reproducer project was inadequate in the first 
place, but I do not think so. Maybe the changes necessary to run this ancient 
setup with the oldest versions of Maven and used plugins necessary to build in 
2021.
* I even checked with Maven Antrun, if the base directory was changed using the 
setting for the dependency-reduced POM (DRP) location: {code:xml}
<target>
  <echo>[basedir] ${basedir}</echo>
  <echo>[project.basedir] ${project.basedir}</echo>
</target>{code}
* Next, I upgraded to my usual setting: Maven 3.6.3 - not the latest, but still 
a pretty much recent version - and also upgraded to Shade 3.2.4, Site 3.9.1 and 
PIP 3.1.1. Again, no issues with a changed base directory.

*Conclusion:* Either this problem does not exist anymore in all but ancient 
setups and the issue can be closed, also removing the warning from the 
{{dependencyReducedPomLocation}} property help text, or we need another 
reproducer project from someone who is still suffering from this problem.

[~mxm], [~elharo], in 2016 and 2020 the two of you wrote that this problem 
still exists. If you would please so kind to provide reproducer projects here, 
I think it would shed light on the issue. Otherwise the issue is just hearsay 
and will forever block MSHADE-124.

----

*Update:* Here is the updated POM with the minimal versions needed to build 
under Maven 3.2.3 or later. Just overwrite the POM from the original ZIP file 
attached to this project with it.

{code:xml}
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.bug</groupId>
  <artifactId>shade-site-bug</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>shade-site-bug</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.7</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <id>shade-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <!--  Comment out this line to see a working site...  -->
              
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
              <minimizeJar>true</minimizeJar>
              <!--  Or this relocation...  -->
              <relocations>
                <relocation>
                  <pattern>org.apache</pattern>
                  <shadedPattern>shaded.org.apache</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>display-basedir</id>
            <phase>package</phase>
            <configuration>
              <target>
                <echo>[basedir] ${basedir}</echo>
                <echo>[project.basedir] ${project.basedir}</echo>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>
{code}


was (Author: kriegaex):
Because I want to use 
{{<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>}}
 in my own project and did not notice any issues with it, I became curious, 
trying to reproduce this problem the documentation is still warning about in 
Maven Shade 3.2.4. I wondered if it was an issue with older plugin or Maven 
versions. So I downloaded the sample project attached here and tried to 
reproduce it, running on Java 8 and compiling with Java 8 source/target. 
Findings:
* Maven 3.0.x is no longer working because it wants to download using HTTP, but 
Maven Central needs HTTPS nowadays.
* Next, I tried Maven 3.1.1. Because of [this 
problem|https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound], 
I upgraded to Maven Shade 2.1 and Maven Site 3.3, as recommended.
* The next problem was with site generation because it could not find a class, 
requiring me to specify a version for Project Info Reports (PIP). I chose 2.7, 
which was released about the same time as Site 3.3.
* There again, I had problems with HTTP instead of HTTPS download, this time 
inside Site 3.3, so I upgraded to Maven 3.2.3 which was said to have fixed 
HTTPS-related download problems.
* Finally, I could run `mvn clean install site`, but did not see any issues 
with site generation. Maybe the reproducer project was inadequate in the first 
place, but I do not think so. Maybe the changes necessary to run this ancient 
setup with the oldest versions of Maven and used plugins necessary to build in 
2021.
* I even checked with Maven Antrun, if the base directory was changed using the 
setting for the dependency-reduced POM (DRP) location: {code:xml}
<target>
  <echo>[basedir] ${basedir}</echo>
  <echo>[project.basedir] ${project.basedir}</echo>
</target>{code}
* Next, I upgraded to my usual setting: Maven 3.6.3 - not the latest, but still 
a pretty much recent version - and also upgraded to Shade 3.2.4, Site 3.9.1 and 
PIP 3.1.1. Again, no issues with a changed base directory.

*Conclusion:* Either this problem does not exist anymore in all but ancient 
setups and the issue can be closed, also removing the warning from the 
{{dependencyReducedPomLocation}} property help text, or we need another 
reproducer project from someone who is still suffering from this problem.

[~mxm], [~elharo], in 2016 and 2020 the two of you wrote that this problem 
still exists. If you would please so kind to provide reproducer projects here, 
I think it would shed light on the issue. Otherwise the issue is just hearsay 
and will forever block MSHADE-124.

----

*Update:* Here is the updated POM with the minimal versions needed to build 
under Maven 3.2.3 or later. Just overwrite the POM from the original ZIP file 
attached to this project with it.

{code:xml}
<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.bug</groupId>
  <artifactId>shade-site-bug</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>shade-site-bug</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>2.7</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <id>shade-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <!--  Comment out this line to see a working site...  -->
              
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
              <minimizeJar>true</minimizeJar>
              <!--  Or this relocation...  -->
              <relocations>
                <relocation>
                  <pattern>org.apache</pattern>
                  <shadedPattern>shaded.org.apache</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>display-basedir</id>
            <phase>package</phase>
            <configuration>
              <target>
                <echo>[basedir] ${basedir}</echo>
                <echo>[project.basedir] ${project.basedir}</echo>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

</project>
{code}

> Site not generated correctly when overriding dependencyReducedPomLocation 
> with relocation
> -----------------------------------------------------------------------------------------
>
>                 Key: MSHADE-145
>                 URL: https://issues.apache.org/jira/browse/MSHADE-145
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Windows XP, Java 6 Update 24, Maven 3.0.4
>            Reporter: Anthony Whitford
>            Priority: Major
>         Attachments: shade-site-bug.zip
>
>
> My release failed because the project uses the {{maven-shade-plugin}} and it 
> generated a {{dependency-reduced-pom.xml}} in the {{basedir}}, so the release 
> plugin complains that there are local, uncommitted modifications.
> To get my release working, I overrode the {{dependencyReducedPomLocation}} 
> configuration parameter to place it in {{project.build.directory}}:
> {code:xml}
> <configuration>
>   
> <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
>   ...
> </configuration>
> {code}
> My release worked, but then I noticed that this had a nasty side effect:  my 
> site was not generated properly!
> The project has {{src\site}} with a {{site.xml}} and APT pages.  Those were 
> no longer generated...  I have no idea how one thing is connected to the 
> other, but I did prove it by creating a sample application that illustrates 
> the problem.
> Note that the problem seems to a combination of at least 2 things:
> * {{dependencyReducedPomLocation}}
> * {{relocations}}
> In other words, if you comment out the {{dependencyReducedPomLocation}} or 
> the {{relocations}}, you can see the site being generated correctly.  But if 
> you have these, then the site will NOT generate properly.
> To be clear, the site generation is incorrect if you don't see the menu 
> layout like:
> * About
> ** Introduction 
> ** Usage 
> * Project Documentation
> * Project Information 
> A broken site, you will notice that the About menu and Usage page do not 
> exist, for example.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to