Uploaded image for project: 'Maven Shade Plugin'
  1. Maven Shade Plugin
  2. MSHADE-345

Package relocation appears not to work with Scala

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      (Apologies if this is a known issue, I searched but couldn't find it.)

      I have a small pom.xml that's simply pulling in two dependent libraries from Maven, and shading them:

      <?xml version="1.0" encoding="UTF-8"?>
      <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/maven-v4_0_0.xsd">
      
          <modelVersion>4.0.0</modelVersion>
      
          <groupId>com.couchbase.client</groupId>
          <artifactId>scala-deps</artifactId>
          <version>1.1.1-SNAPSHOT</version>
          <packaging>jar</packaging>
      
          <name>Couchbase Scala Dependencies</name>
          <description>Shadowing dependencies for Scala prokect</description>
      
          <dependencies>
              <dependency>
                  <groupId>com.github.plokhotnyuk.jsoniter-scala</groupId>
                  <artifactId>jsoniter-scala-core_2.12</artifactId>
                  <version>1.0.0</version>
              </dependency>
      
              <dependency>
                  <groupId>com.github.plokhotnyuk.jsoniter-scala</groupId>
                  <artifactId>jsoniter-scala-macros_2.12</artifactId>
                  <version>1.0.0</version>
              </dependency>
          </dependencies>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-shade-plugin</artifactId>
                      <version>3.2.1</version>
                      <configuration>
                          <relocations>
                              <relocation>
                                  <pattern>com.github.plokhotnyuk</pattern>
                                  <shadedPattern>com.couchbase.client.scala.deps.plokhotnyuk</shadedPattern>
                              </relocation>
                          </relocations>
                          <createSourcesJar>true</createSourcesJar>
                          <shadeSourcesContent>true</shadeSourcesContent>
                          <shadedArtifactAttached>true</shadedArtifactAttached>
                      </configuration>
                      <executions>
                          <execution>
                              <phase>package</phase>
                              <goals>
                                  <goal>shade</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>
      </project> 

      From this I expect to get an uber-jar containing those dependencies, with classfiles inside com/couchbase/client/scala/deps/plokhotnyuk/jsoniter_scala/..., and with those files starting "package com.couchbase.client.scala.deps.plokhotnyuk...".

      However, while the files are moved to the correct file structure, the package names aren't adjusted.  Here's a screenshot from the sources jar:

       

      And my experiments with the binary jar itself seem to indicate that the same issue exists at the bytecode level in the regular jar too, e.g. the classfiles are in the right place but the package hasn't been changed.

       

      Attachments

        1. image (4).png
          87 kB
          Graham Pople

        Activity

          People

            Unassigned Unassigned
            programmatix Graham Pople
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: