You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Alexander Kriegisch (Jira)" <ji...@apache.org> on 2021/04/04 03:24:00 UTC

[jira] [Commented] (MSHADE-217) Shaded sources out of sync with shaded jar.

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

Alexander Kriegisch commented on MSHADE-217:
--------------------------------------------

You have to make sure that your own module actually creates a source JAR in the first place. Only then it will also be included in the shaded source JAR. So just add something like this to the modules you wish to be included in the source JAR:

{code:xml}
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-source-plugin</artifactId>
  <version>3.2.1</version>
  <configuration>
    <!-- Re-create original source JAR in order to avoid re-shading already shaded JAR in non-clean builds -->
    <forceCreation>true</forceCreation>
  </configuration>
  <executions>
    <execution>
      <id>attach-sources</id>
      <phase>package</phase>
      <goals>
        <goal>jar-no-fork</goal>
      </goals>
    </execution>
  </executions>
</plugin>
{code}

The commented {{forceCreation}} option is only necessary if you shade in the same module where the sources are.

> Shaded sources out of sync with shaded jar.
> -------------------------------------------
>
>                 Key: MSHADE-217
>                 URL: https://issues.apache.org/jira/browse/MSHADE-217
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 2.4.3
>            Reporter: Zoltan Farkas
>            Priority: Major
>
> I am using the maven shade plugin to patch open source libraries. (fix bugs...)
> this is the configuration I use:
> {noformat}
> <plugin>
>                     <groupId>org.apache.maven.plugins</groupId>
>                     <artifactId>maven-shade-plugin</artifactId>
>                     <version>2.4.3</version>
>                     <executions>
>                         <execution>
>                             <phase>package</phase>
>                             <goals>
>                                 <goal>shade</goal>
>                             </goals>
>                             <configuration>                                
>                                 <artifactSet>
>                                     <includes>
>                                       <include>${project.groupId}:${project.artifactId}:${original.version}</include>
>                                     </includes>
>                                 </artifactSet>
>                                 <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
>                                 <createSourcesJar>true</createSourcesJar>
>                                 <shadeSourcesContent>true</shadeSourcesContent>
>                             </configuration>
>                         </execution>
>                     </executions>
>                 </plugin>
> {noformat}
> The java classes I have in my project, are correctly included in the shaded jar and overwrite the dependency classes, however the source artifact generated by the shade plugin does not include the sources from my project.
> Can this be improved so that source and class behaviour is consistent?
> is there a workarround?



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