0

I'm trying to make POM.xml generate two jar files. One with all the classes, the other excluding one of the classes.

The file i'm trying to exclude is named 'ExcludeMe1.java.'I'm new but it's not my FIRST rodeo, in the code below I've excluded ExcludeMe1.class. But the size of the jar file remains unchanged, and I believe it to still contain the class of which I am excluding. Here's what I mean...

    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
            <execution>
              <id>make-assembly</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                  <appendAssemblyId>false</appendAssemblyId>
                  <archive>
                    <manifest>
                      <mainClass>com.costanzo.mavendemo.MavenDemo1</mainClass>
                    </manifest>
                  </archive>
                  <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
                </configuration>
            </execution>
            <execution>
              <id>make-assembly22</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                  <excludes>
                      <exclude>${project.basedir}/target/excludeMe/ExcludeMe1.class</exclude>
                  </excludes>
                  <archive>
                    <manifest>
                      <mainClass>com.costanzo.mavendemo.MavenDemo1</mainClass>
                    </manifest>
                  </archive>
                  <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
                </configuration>
            </execution>
          </executions>
      </plugin>
    </plugins>

What I expect to be happening is the exclusion of the class file, which size is 1KB. So instead of getting both jar's as size N I expect N, and N-1.

I am still really new to Maven, so hopefully yall can understand. Always ask questions if you need I'll be checking this thing frequently as it is a high priority project.

Andrew Costanzo
  • 97
  • 1
  • 1
  • 6
  • Why do you want to make two jars of a single project? Using maven-assembly-plugin is done why? Make an executable jar? This is something different? Excluding files is generally a bad idea...either the class you are excluding should not being part of the project or simply if not ready being put onto a branch in your version control... – khmarbaise May 23 '19 at 19:14
  • Basically I've demonstrated this basic concept in order to receive answers for hiding folders. If I were given an example on say a class file I'd be able to figure out a folder from there – Andrew Costanzo May 23 '19 at 19:27

2 Answers2

0

Excluding a single class using maven to my knowledge is not possible. Exclusion of jars is possible.

Akin Okegbile
  • 1,108
  • 19
  • 36
0

You can only exclude a jar file from the building process.