1

As it can be read in this answer, SBT (sbt-assembly) allows package renaming in the project that is importing the renamed library. e.g:

I want to use the package org.pfcoperez.algorithms in my project but I want to "see" it, that is: be able to import it, as com.algorithms.

I know that Maven Shade Plugin can relocate dependencies as described here:

         <relocations>
            <relocation>
              <pattern>org.codehaus.plexus.util</pattern>
              <shadedPattern>org.shaded.plexus.util</shadedPattern>
              <excludes>
                <exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
                <exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
              </excludes>
            </relocation>
          </relocations>

I could use that to generate an intermediate jar having the new package structure. However, I'd like to avoid using that intermediate artifact.

Is it possible to do this in a Maven project as it is in SBT? If the answer is yes, how could it be done?

Community
  • 1
  • 1

1 Answers1

1

I think you can attach the shade:shade goal to the process-resources phase and set up the generated jar as a system dependency, so that it's available during the compile phase.

I wouldn't recommend it however, as your IDE is almost certainly going to have problems understanding your POM.

Dan Berindei
  • 7,054
  • 3
  • 41
  • 48