0

In some of my maven modules (example myChild) I use maven-jar-plugin to create some additional jar, named here my-plugin.jar. This my-plugin.jar should be only the part of the entire module - myChild.jar.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=...>
<modelVersion>4.0.0</modelVersion>

<artifactId>myChild</artifactId>

<parent>
<groupId>org.group</groupId>
<artifactId>myParent</artifactId>
<version>1.0</version>
</parent>

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>build-plugins-jar</id>
                <phase>package</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                    <includes>
                        <include>......</include>
                    </includes>
                    <finalName>my-plugin</finalName>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
</build>

<dependencies>
 ...........
</dependencies>

When I want to use myChild module in the another maven module (example myExternal) I add the dependency on myChild. But the compilation of myExternal failed because of errors like: method does not override or implement a method from a supertype. When I removed two @Override annotations, the number of errors decreased by two. It seems that Java 1.4 is used. But parent POM has maven-compiler-plugin with source and target 1.7. What more is curious, the myChild module compiles well. But when some other module which uses myChild is compiling, then the above errors occurs.

LancerX
  • 1,211
  • 7
  • 23
  • 40

1 Answers1

0

Ok, according to published code you need to move maven-compiler-plugin configuration from plugins to pluginsManagement sections to be visible in all submodules.

Parent POM sample configuration

<pluginManagement>
    <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
    </plugin>
</pluginManagement>
MariuszS
  • 30,646
  • 12
  • 114
  • 155