micronaut-projects / micronaut-maven-plugin

Maven plugin to execute Micronaut applications
https://micronaut-projects.github.io/micronaut-maven-plugin/latest/
Apache License 2.0
21 stars 21 forks source link

Basic element 'filter' must not contain child elements #227

Closed flashpixx closed 3 years ago

flashpixx commented 3 years ago

Hello,

I'm try to build a Kafka Micronaut application with Spark components. Within a Spark dependency I have got some files .SF, .DSA and *.RSA and these files break after the UberJar is build the starting process with

Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

So I try to configure the micronaut-maven-plugin with

<plugin>
    <groupId>io.micronaut.build</groupId>
    <artifactId>micronaut-maven-plugin</artifactId>
    <configuration>
        <filters>
            <filter>
                <artifact>*:*</artifact>
                <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                </excludes>
            </filter>
        </filters>
    </configuration>
</plugin>

But this creates the build error:

Failed to execute goal io.micronaut.build:micronaut-maven-plugin:3.0.2:graalvm-resources (default-graalvm-resources) on project myproject: Unable to parse configuration of mojo io.micronaut.build:micronaut-maven-plugin:3.0.2:graalvm-resources for parameter filters: Basic element 'filter' must not contain child elements

How can I apply such filter to remove the file during the build? I have seen this issue https://github.com/micronaut-projects/micronaut-maven-plugin/issues/101

Is it possible to switch to a normal maven-shade-plugin and how can this be reached?

alvarosanchez commented 3 years ago

That <filters> configuration should be added to the maven-shade-plugin, not the micronaut-maven-plugin.

Give it a try and please let me know.

flashpixx commented 3 years ago

Did I understand it correct, that I must add the Maven-Shade-Plugin to the pom.xml and append also my filters and than it should work?

alvarosanchez commented 3 years ago

Yes, you need to add maven-shade-plugin to your POM. No need to specify a version, that comes from the Micronaut Parent POM.

Then, remove the filters configuration from micronaut-maven-plugin and add it to maven-shade-plugin.

flashpixx commented 3 years ago

I have configured this with

            <plugin>
                <groupId>io.micronaut.build</groupId>
                <artifactId>micronaut-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <configuration>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
            </plugin>

and this work for me. I thin the #101 can be fixed with that solution as well. Thanks for the help