You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thad Humphries <th...@gmail.com> on 2013/05/10 00:27:34 UTC

Include *.class and *.java files with shade plugin

I am using Maven 3.0.5.

I'm attempting to use maven-shade-plugin to merge the *.class and *.java
files from an artifact in my repository into a single jar, along with some
resource files in the current project. However while the resource and
*.class files are in the new artifact's jar, the *.java files aren't there.
The dependency has both a *.jar and a *-sources.jar are in the repository.

The dependency looks like:

    <dependency>
      <groupId>com.mycorp.database</groupId>
      <artifactId>thedb</artifactId>
      <version>${project.version}</version>
    </dependency>

As I said, both thedb-VER.jar and thedb-VER-sources.jar exist.

My plugin looks like this:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <includeSources>true</includeSources>
              <filters>
                <filter>
                  <artifact>com.mycorp.database:thedb</artifact>
                  <includes>
                    <include>**/*.java</include>
                    <include>**/*.class</include>
                  </includes>
                  <excludes>
                    <exclude>META-INF/*</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

How to I get the source files in my new artifact's jar (call it
thedb-new-VER.jar).

-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v, 121-24)

Re: Include *.class and *.java files with shade plugin

Posted by Wayne Fay <wa...@gmail.com>.
Not certain, but this may work. If not, something along these lines
should do it.

PS- Why do you want the Java files?

>         <executions>
           <execution><id>dot-class</id>        <!--note the id field-->
>             <phase>package</phase>
>             <goals>
>               <goal>shade</goal>
>             </goals>
>             <configuration>
>               <includeSources>true</includeSources>
>               <filters>
>                 <filter>
>                   <artifact>com.mycorp.database:thedb</artifact>
>                   <includes>
<!-- *.java removed -->
>                     <include>**/*.class</include>
>                   </includes>
>                   <excludes>
>                     <exclude>META-INF/*</exclude>
>                   </excludes>
>                 </filter>
>               </filters>
>             </configuration>
>           </execution>

           <execution><id>dot-java</id>    <!-- a different id -->
>             <phase>package</phase>
>             <goals>
>               <goal>shade</goal>
>             </goals>
>             <configuration>
>               <includeSources>true</includeSources>
>               <filters>
>                 <filter>

<artifact>com.mycorp.database:thedb:sources</artifact> <!-- or
:source? -->
>                   <includes>
>                     <include>**/*.java</include>
<!-- removed *.class -->
>                   </includes>
>                   <excludes>
>                     <exclude>META-INF/*</exclude>
>                   </excludes>
>                 </filter>
>               </filters>
>             </configuration>
>           </execution>
>         </executions>

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org