1

As the title puts it, I am facing a strange situation with Maven. Given is the output of my debug process, which I ran with mvn install -X command:

[DEBUG] =======================================================================
[WARNING] The POM for sampleModule:sampleModule.msg:jar:1.0.0.qualifier is invalid, transitive dependencies (if any) will not be available: 2 problems were encountered while building the effective model for sampleModule:sampleModule.msg:1.0.0.qualifier
[ERROR] 'dependencies.dependency.systemPath' for sampleModule:org.apache.felix:jar must specify an absolute path but is ${project.basedir}/../org.apache.felix/felix.jar @ 
[ERROR] 'dependencies.dependency.systemPath' for sampleModule:com.google.protobuf:jar must specify an absolute path but is ${project.basedir}/../com.google.protobuf/protobuf-java-2.5.0.jar @ 

which tells me that my sampleModule.msg module is somewhat "not-okay". However, a bit below I see this line:

[DEBUG]    sampleModule:sampleModule.msg:jar:1.0.0.qualifier:compile

Note that it says "compile" and there is no error afterwards.

Here is the pom.xml file of sampleModule.msg module of mine:

<?xml version="1.0" encoding="UTF-8"?>
<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>
   <parent>
      <groupId>sampleModule</groupId>
      <artifactId>sampleModule.master</artifactId>
      <relativePath>../pom.xml</relativePath>
      <version>1.0.0-SNAPSHOT</version>
   </parent>
   <groupId>sampleModule</groupId>
   <artifactId>sampleModule.msg</artifactId>
   <name>sampleModule.msg</name>
   <version>1.0.0.qualifier</version>
   <packaging>jar</packaging>
   <dependencies>
      <dependency>
         <groupId>sampleModule</groupId>
         <artifactId>org.apache.felix</artifactId>
         <version>1.0.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../org.apache.felix/felix.jar</systemPath>
      </dependency>
      <dependency>
         <groupId>sampleModule</groupId>
         <artifactId>com.google.protobuf</artifactId>
         <version>2.5.0</version>
         <scope>system</scope>
         <systemPath>${project.basedir}/../com.google.protobuf/protobuf-java-2.5.0.jar</systemPath>
      </dependency>
   </dependencies>
   <build>
      <sourceDirectory>src/</sourceDirectory>
      <plugins>
         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
               <source>${jdk.version}</source>
               <target>${jdk.version}</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.1</version>
            <configuration>
               <archive>
                  <manifest>
                     <addClasspath>true</addClasspath>
                     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                  </manifest>
                  <manifestEntries>
                     <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                     <Bundle-Version>${project.version}</Bundle-Version>
                     <Bundle-ClassPath>.</Bundle-ClassPath>
                     <Export-Package>sampleModule.msg</Export-Package>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>
        <plugin>
       <artifactId>maven-antrun-plugin</artifactId>
       <executions>
         <execution>
           <id>generate-sources</id>
           <phase>generate-sources</phase>
           <configuration>
             <tasks>
               <mkdir dir="target/src-gen"/>
               <exec executable="protoc">
                 <arg value="--java_out=target/src-gen"/>
                 <arg value="target/proto/Empty.proto"/>
                 <arg value="target/proto/ComponentState.proto"/>
               </exec>
             </tasks>
             <sourceRoot>target/src-gen</sourceRoot>
           </configuration>
           <goals>
             <goal>run</goal>
           </goals>
         </execution>
       </executions>
     </plugin>
      </plugins>
   </build>
</project>

I have the same problem with another module. Shows 5 dependency errors, yet it compiles. I am kinda confused. If we solve this, I'll get rid of the other one too.

Therefore my question is, should I take this error seriously? Is there a reason for this contradiction?

Schütze
  • 1,044
  • 5
  • 28
  • 48

1 Answers1

0

The key point is:

..., transitive dependencies (if any) will not be available: ...

If there aren't any, you're lucky – at the moment. Have you tried to use sampleModule.msg-...jar at runtime already? Does it work?

(BTW, dots as separators in the <artifactId> are unusal, use hyphens instead.)

See also Maven / POM Reference, Dependencies:

  • groupId, artifactId, version:
    ...

    Since the dependency is described by Maven coordinates, you may be thinking: "This means that my project can only depend upon Maven artifacts!" The answer is, "Of course, but that's a good thing." This forces you to depend solely on dependencies that Maven can manage. There are times, unfortunately, when a project cannot be downloaded from the central Maven repository. For example, a project may depend upon a jar that has a closed-source license which prevents it from being in a central repository. There are three methods for dealing with this scenario.

    1. Install the dependency locally using the install plugin. The method is the simplest recommended method. For example:

      mvn install:install-file -Dfile=non-maven-proj.jar -DgroupId=some.group -DartifactId=non-maven-proj -Dversion=1 -Dpackaging=jar
      

      Notice that an address is still required, only this time you use the command line and the install plugin will create a POM for you with the given address.

    2. Create your own repository and deploy it there. This is a favorite method for companies with an intranet and need to be able to keep everyone in synch. There is a Maven goal called deploy:deploy-file which is similar to the install:install-file goal (read the plugin's goal page for more information).
    3. Set the dependency scope to system and define a systemPath. This is not recommended, however, but leads us to explaining the following elements:

...

  • systemPath:
    Is used only if the the dependency scope is system. Otherwise, the build will fail if this element is set. The path must be absolute, so it is recommended to use a property to specify the machine-specific path (more on properties below), such as ${java.home}/lib. Since it is assumed that system scope dependencies are installed a priori, Maven will not check the repositories for the project, but instead checks to ensure that the file exists. If not, Maven will fail the build and suggest that you download and install it manually.

[Emphasizes by me.]

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Thank you for the recommendations, I'll work on them once I get the whole system running. As for your question, yes it works. So I think I can safely assume that I am on the safe track. And for me it is the second option, local repository one. – Schütze Jun 30 '16 at 12:10
  • @Schütze The second option does **not** concern Maven's _local_ repositories (where you `mvn install` to) it's regarding _remote_ repositories (where you `mvn deploy` to). – Gerold Broser Jul 01 '16 at 08:12
  • I am extremely confused now. Should I or should I not go for `deploy.deploy-file` method if I **only** want to utilize my local repository? – Schütze Jul 01 '16 at 08:19
  • @Schütze Please read [Maven / Introduction to Repositories](https://maven.apache.org/guides/introduction/introduction-to-repositories.html) in particular and [Maven: The Complete Reference](http://books.sonatype.com/mvnref-book/reference/index.html) in general. – Gerold Broser Jul 01 '16 at 08:21