Я перешел на новую настройку, и теперь команда mvn clean compile
не работает с этим:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project OpenPatricianModel: Compilation failure: Compilation failure:
[ERROR] /home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java/ch/sahits/game/openpatrician/model/ship/impl/ShipWeaponsLocationFactory.java:[80,71] cannot find symbol
[ERROR] symbol: class WeaponLocation
[ERROR] location: class ch.sahits.game.openpatrician.data.xmlmodel.weapon.WeaponLocations
[ERROR] /home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java/ch/sahits/game/openpatrician/model/ship/impl/ShipWeaponsLocationFactory.java:[92,58] cannot find symbol
[ERROR] symbol: class WeaponLocation
[ERROR] location: class ch.sahits.game.openpatrician.data.xmlmodel.weapon.WeaponLocations
[ERROR] /home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java/ch/sahits/game/openpatrician/model/ModelConfiguration.java:[105,30] cannot find symbol
[ERROR] symbol: class Cities
[ERROR] location: class ch.sahits.game.openpatrician.data.xmlmodel.map.Map
[ERROR] /home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java/ch/sahits/game/openpatrician/model/city/impl/City.java:[151,71] cannot find symbol
[ERROR] symbol: class Cities
[ERROR] location: class ch.sahits.game.openpatrician.data.xmlmodel.map.Map
Из ошибки видно, что классы не могут быть найдены. Эти классы были сгенерированы на этапе generate-sources
, а затем добавлены к ресурсам с помощью build-helper-maven-plugin
. Поэтому это выглядит иначе, чем Почему сгенерированные источники Maven не компилируются?< /а>
Запуск команды maven с -X
показывает, что выходная папка сгенерированных источников Java фактически находится в пути к классам, и файлы даже обнаружены как устаревшие (поскольку они были недавно созданы):
[DEBUG] Using compiler 'javac'.
[DEBUG] Adding /home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated-sources/annotations to compile source roots:
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated/main/java
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated/src/main/java
[DEBUG] New compile source roots:
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/src/main/java
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated/main/java
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated/src/main/java
/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated-sources/annotations
Однако кажется, что эти источники не скомпилированы.
Вот части файла effictve pom:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<xsdOptions>
<xsdOption>
<xsd>src/main/resources/map.xsd</xsd>
<bindingFile>src/main/resources/jaxb-binding.xjb</bindingFile>
<packagename>ch.sahits.game.openpatrician.data.xmlmodel.map</packagename>
</xsdOption>
<xsdOption>
<xsd>src/main/resources/weaponLocation.xsd</xsd>
<bindingFile>src/main/resources/jaxb-binding.xjb</bindingFile>
<packagename>ch.sahits.game.openpatrician.data.xmlmodel.weapon</packagename>
</xsdOption>
</xsdOptions>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.7.0</extension>
</extensions>
</configuration>
</execution>
</executions>
<configuration>
<extensions>
<extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.7.0</extension>
</extensions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>test</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>/home/andi/development/intellij/OpenPatrician/OpenPatricianModel/target/generated/main/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>process-resources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resource</id>
<phase>process-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>14</release>
<source>13</source>
<target>13</target>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<release>14</release>
<source>13</source>
<target>13</target>
</configuration>
</execution>
</executions>
<configuration>
<release>14</release>
<source>13</source>
<target>13</target>
</configuration>
</plugin>
Проект можно скомпилировать из среды IDE (IntelliJ), и приложение запустится.