scala maven plugin compile failing with the "version cannot be empty" for a random dependency

3.1k views Asked by At

Long time listener first time caller. :-)

I'm trying to slowly move our java webapp at work over to scala and the first small step is getting some scala code to compile in our project. I've added the scala-maven-plugin to our webapp specific pom like so:

    ...
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <!--version>2.10.3</version-->
        <version>2.7.2</version>
    </dependency>   
  ....
 <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>add-source</id>
        <phase>generate-sources</phase>
        <goals>
          <goal>add-source</goal>
        </goals>
        <configuration>
          <sources>
            <source>src/main/scala</source>
          </sources>
        </configuration>
      </execution>
    </executions>
  </plugin>

    <plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>scala-compile-first</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>add-source</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>scala-test-compile</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

and other variations but this is my latest.

Now this is the pom for the webapp we have another pom for a jar that contains some common code we share with other apps. And both projects have dependencies on other internal jars.

My scala class is a little tiny controller located in src/main/scala.

The error I'm getting when I run a maven package or any maven command really is:

[INFO] --- scala-maven-plugin:3.1.6:compile (scala-compile-first) @ producttool-webapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.663s
[INFO] Finished at: Thu Jan 16 15:34:09 PST 2014
[INFO] Final Memory: 16M/213M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.1.6:compile (scala-compile-fi
rst) on project producttool-webapp: Execution scala-compile-first of goal net.alchim31.maven:scala-m
aven-plugin:3.1.6:compile failed: For artifact {company.com:vine-xml:null:jar}: The version cannot be em
pty. -> [Help 1]

I am seeing a warning/error when I debug this build but it doesn't make sense to me:

[WARNING] The POM for company.com:vine-xml:jar:1.11.1 is invalid, transitive dependencies (if any) will
not be available: 2 problems were encountered while building the effective model for company.com:vine-xm
l:
[ERROR] 'modelVersion' is missing. @ company.com:vine-xml:[unknown-version]
[ERROR] 'version' is missing. @ company.com:vine-xml:[unknown-version]

The child jar project we depend on is dependent on that jar and it is specified in their pom.xml and it's coming through in the debug as well like so:

[DEBUG]       company.com:vine-xml:jar:1.12.2:compile
...
[DEBUG]     testArtifact: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG]     includeArtifact: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG]     startProcessChildren: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG]       testArtifact: artifact=javax.xml.bind:jaxb-api:jar:2.1:compile
[DEBUG]       omitForNearer: omitted=javax.xml.bind:jaxb-api:jar:2.1:compile kept=javax.xml.bind:jax

I'm wondering if maybe my scala-maven-plugin isn't seeing any of the dependencies and asking how I'd fix that. Or is there maybe a way to ignore errors like these that I can turn on in the scala-maven-plugin.

Thanks for your help.

1

There are 1 answers

0
Robert Beltran On

Well I'm not sure if there is another fix but excluding the offending jar from a completely different sub project like below worked for me.

    <exclusion>
    <artifactId>vine-xml</artifactId>
    <groupId>company.com</groupId>
    </exclusion>