Во-первых, почему вы вручную связываете плагины с жизненным циклом? Не имеет смысла. Используйте обычную банку для упаковки. Правильно определите версию компилятора

р проекта maven, приведенный ниже, показывает ошибку вmodule-info.java в Затмении Кислорода:

log4j.api cannot be resolved to a module. 

Если я уберу строку

<packaging>pom<packaging>

из pom.xml ошибка исчезает. Тем не менее, мне нужно использовать упаковку пом. Если я использую Java8 без определений модулей, часть maven в моем примере из реального мира работает очень хорошо. Попытка перехода на Java9 столкнула меня с этой новой проблемой. Сначала я подумал, что не буду правильно ссылаться на зависимость log4j. Затем я узнал, что это как-то связано с упаковкой pom, которая мне нужна в моем многомодульном проекте. Я создал минимальный пример, который приведен ниже, чтобы вы могли воспроизвести сообщения об ошибках в Eclipse.

=> Это ошибка в плагине M2E (1.8.2.20171007-0217)?

=> Если нет, как мне адаптировать мой файл pom.xml для работы с Java9?

Связанные вопросы:

Как использовать log4j с maven и java9?

Импорт Java-9-Jigsaw-Maven-Project в Eclipse Oxygen 4.7 не работает

Модули Java 9 и JUnit 4

Может ли Maven создать объявление модуля

Где я должен поставить модульные тесты при переносе проекта Java 8 в Jigsaw?

Какой модуль я должен требовать в Java 9 для использования JPA?

Список Java-модулей:http://download.java.net/java/jigsaw/docs/api/overview-summary.html

Мин пример проекта (мой реальный пример более сложный):

pom.xml:

<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
    <modelVersion>4.0.0</modelVersion>
    <groupId>Log4JWithJava9</groupId>
    <artifactId>Log4JWithJava9</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <properties>
        <!-- encoding -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>

        <plugins>

            <!-- plugin for resource phase -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>resource-execution</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- plugin for compile phase (and test-compile phase) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <!-- specify current java version here: -->
                    <source>9</source>
                    <target>9</target>
                </configuration>
                <executions>
                    <execution>
                        <id>compile-execution</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile-execution</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- ### PACKAGE ### phase -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>package-execution</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>

                        </configuration>
                    </execution>
                </executions>
            </plugin>

        <!-- plugin for install phase -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>install-execution</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install</goal>
 ,                   </goals>
                </execution>
            </executions>
        </plugin>

        </plugins>
    </build>

    <dependencies>

        <!-- log4j -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.9.1</version>
        </dependency>

    </dependencies>

</project>

module-info.java

module Log4JWithJava9 {
    exports isi.share;      
    requires javafx.base;
    requires log4j.api; 
}

Main.java

package isi.share;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;


public class Main {

    private static Logger sysLog = LogManager.getLogger(Main.class);

    public static void main(String[] args) {

    }

}

Выход для конфигурации Maven Run с чистой установкой:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Log4JWithJava9 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Log4JWithJava9 ---
[INFO] Deleting D:\EclipseJava\workspace\Log4JWithJava9\target
[INFO] 
[INFO] --- maven-resources-plugin:3.0.2:resources (resource-execution) @ Log4JWithJava9 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\EclipseJava\workspace\Log4JWithJava9\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:compile (compile-execution) @ Log4JWithJava9 ---
[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\EclipseJava\workspace\Log4JWithJava9\target\classes
[INFO] 
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (test-compile-execution) @ Log4JWithJava9 ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (package-execution) @ Log4JWithJava9 ---
[INFO] Building jar: D:\EclipseJava\workspace\Log4JWithJava9\target\Log4JWithJava9-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ Log4JWithJava9 ---
[INFO] Installing D:\EclipseJava\workspace\Log4JWithJava9\pom.xml to C:\Users\eis\.m2\repository\Log4JWithJava9\Log4JWithJava9\0.0.1-SNAPSHOT\Log4JWithJava9-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (install-execution) @ Log4JWithJava9 ---
[INFO] Installing D:\EclipseJava\workspace\Log4JWithJava9\pom.xml to C:\Users\eis\.m2\repository\Log4JWithJava9\Log4JWithJava9\0.0.1-SNAPSHOT\Log4JWithJava9-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.520 s
[INFO] Finished at: 2017-11-10T20:41:10+01:00
[INFO] Final Memory: 15M/52M
[INFO] ------------------------------------------------------------------------

Весь пример проекта Eclipse:

https://github.com/stefaneidelloth/java9MavenEclipse

Используемые инструменты:

Eclipse для разработчиков RCP и RAP, версия Oxygen 1a (4.7.1a) (включая версию M2E 1.8.2.20171007-0217)

Java JDK версия 9.0.1

Ответы на вопрос(0)

Ваш ответ на вопрос