1

I moved to a new setup and now the mvn clean compile command fails with this:

[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

From the error it is clear that classes cannot be found. These classes were generated during the generate-sources phase and then added to the resources with build-helper-maven-plugin. Therefore this seems different than Why are Maven generated-sources not getting compiled?

Running the maven comand with -X shows that the output folder of the generated java sources is actually on the classpath and the files are even detected to be stale (because they are newly created):

[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

It seems however that those sources are not compiled.

Here are parts of the effictve pom file:

  <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>

The project can be compiled from within the IDE (IntelliJ) and the application runs.

hotzst
  • 7,238
  • 9
  • 41
  • 64
  • did you upgrade from a lower version to java 11 or higher? Then you'll need to take a look at your cxf plugins – Paul Jul 17 '20 at 09:18
  • @Paul: No, I did the upgrade to Java 14 earlier and it was working. The only change that I am aware is that I now use Maven 3.6.3 and before it was 3.5.3 (I think) – hotzst Jul 17 '20 at 09:25
  • I'm not sure anymore about the Maven-version, but I had sort of the same problem when upgrading. Eventually, I had to configure this plugin in order for Maven and Java-version to be compatible for generating resources: org.codehaus.mojo jaxb2-maven-plugin 2.5.0 – Paul Jul 17 '20 at 09:30

0 Answers0