admin管理员组

文章数量:1310059

I have a simple assignment for class to practice maven and I am completely lost with the pom file part. Our Java file just takes in either "PDF" or "XLS" then reads a csv file and populates either the PDF or XLS with a table containing that csv file data. I don't get how you know what to add and how to add it, regardless I was able to make the Java program and the pom file, but it always makes two jars for some reason. One is a shaded jar and the other is a default one.

What to Submit
Your assignment2.jar Fat Jar and your sample.csv input file for testing.

We will run the following to test your program:

$java -jar assignment2.jar PDF sample.csv

It should've just made ONE fat jar using the shade plugin but each time I get both of the jars.

assignment2-1.0-SNAPSHOT-shaded.jar  assignment2.jar  classes  generated-sources  generated-test-sources  maven-archiver  maven-status  test-classes

Here is my pom file.

<project xmlns=".0.0"
         xmlns:xsi=";
         xsi:schemaLocation=".0.0 .0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>.example</groupId>
    <artifactId>assignment2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Assignment 2 Maven Project</name>

    <properties>
        <mavenpiler.source>17</mavenpiler.source>
        <mavenpiler.target>17</mavenpiler.target>
    </properties>

    <dependencies>
        <!-- iText Core PDF generation -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>kernel</artifactId>
            <version>7.2.5</version>
        </dependency>

        <!-- .itextpdf/layout -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>layout</artifactId>
            <version>7.2.5</version>
        </dependency>


        <!-- Apache POI for Excel (XLSX) manipulation -->
        <dependency>
            <groupId>.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>5.2.3</version>
        </dependency>

        <!-- Required for Apache POI XML operations -->
        <dependency>
            <groupId>.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>4.1.2</version>
        </dependency>

        <!-- XMLBeans dependency for POI -->
        <dependency>
            <groupId>.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>5.1.1</version>
        </dependency>
    </dependencies>

    <build>
        <!-- Set the final name of the JAR file -->
        <finalName>assignment2</finalName>
        <plugins>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>

            <!-- Use the Maven Shade Plugin for creating a fat JAR -->
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedArtifactClassifier>all</shadedArtifactClassifier>
                            <transformers>
                                <transformer implementation=".apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>.example.Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Is there a dependency or plugin that I'm missing?

Please do not be rude about my code. This is legitimately my first ever maven project. I realize this code is not good, which is why I'm asking you guys for help.

本文标签: javaHow to fix this POM file to make one fat jarStack Overflow