2013-06-19 91 views
0

我有一些麻煩讓Maven原生插件工作。問題是編譯時出現IllegalStateException:「No basedir set」。堆棧跟蹤如下:從本地-maven插件沒有basedir集

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile (default-compile) on project native-ipc: Execution default-compile of goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile failed: No basedir set 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) 
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:601) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-compile of goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:compile failed: No basedir set 
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110) 
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
... 19 more 
Caused by: java.lang.IllegalStateException: No basedir set 
at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:286) 
at org.codehaus.mojo.natives.NativeSources.getFiles(NativeSources.java:183) 
at org.codehaus.mojo.natives.NativeSources.getAllSourceFiles(NativeSources.java:240) 
at org.codehaus.mojo.natives.plugin.NativeCompileMojo.execute(NativeCompileMojo.java:167) 
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
... 20 more 

天然-IPC pom.xml的是:

<?xml version="1.0" encoding="UTF-8"?> 
<project> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>native-ipc</groupId> 
    <artifactId>native-ipc</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>so</packaging> 

<properties> 
    <basedir>${project.basedir}</basedir> 
</properties> 
<parent> 
    <groupId>com.discovix</groupId> 
    <artifactId>discovix-parent</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>../pom.xml</relativePath> 
</parent> 


<build> 
    <plugins> 
     <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>native-maven-plugin</artifactId> 
      <extensions>true</extensions> 
      <configuration> 
       <javahOS>MacOS</javahOS> 
       <sources> 
        <source> 
         <directory>src/main/cpp</directory> 
         <fileNames> 
          <fileName>ipc.cpp</fileName> 
         </fileNames> 
         <includes> 
          <include>${java.home}/include/*</include> 
         </includes> 
        </source> 
        <source> 
         <includes> 
          <include>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/</include> 
          <include>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/darwin/</include> 
         </includes> 
        </source> 
       </sources> 
       <linkerStartOptions> 
        <linkerStartOption>-shared -Wall</linkerStartOption> 
       </linkerStartOptions> 
       <compilerProvider>generic-classic</compilerProvider> 
       <compilerExecutable>g++</compilerExecutable> 
      </configuration> 
      <executions> 
       <execution> 
        <id>javah</id> 
        <phase>generate-sources</phase> 
        <configuration> 
         <javahOS>MacOS</javahOS> 
         <javahProvider>default</javahProvider> 
         <javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory> 
         <workingDirectory>${project.basedir}</workingDirectory> 
         <javahClassNames> 
          <javahClassName>com.discovix.projects.glimmerglass.jni.posix.IPC</javahClassName> 
         </javahClassNames> 
         <goals> 
          <goal>javah</goal> 
         </goals> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

<dependencies> 
    <dependency> 
     <groupId>com.discovix</groupId> 
     <artifactId>network-analyzer</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
</dependencies> 
</project> 

和父POM很簡單:

<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>com.discovix</groupId> 
    <artifactId>discovix-parent</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Discovix GlimmerGlass</name> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.8.1</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <modules> 
     <module>network-analyzer</module> 
     <module>native-ipc</module> 
     <module>generators</module> 
    </modules> 

    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>native-maven-plugin</artifactId> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

</project> 

我覺得我失去了一些東西明顯。任何幫助,將不勝感激。

-RB

回答

0

如果別人運行到這一點,這個問題似乎是標記順序。廣告將原始pom.xml移到了macosx子模塊中。下面的maven文件起作用了。

<?xml version="1.0" encoding="UTF-8"?> 
<project> 
    <modelVersion>4.0.0</modelVersion> 

    <!-- @todo Break this out into a parent pom and child modules once we have multiple platforms to support. --> 

    <groupId>com.discovix</groupId> 
    <artifactId>macosx</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jnilib</packaging> 

    <name>JNI - MacOSX</name> 

    <parent> 
     <groupId>com.discovix</groupId> 
     <artifactId>discovix-parent</artifactId> 
     <version>1.0-SNAPSHOT</version> 
     <relativePath>../pom.xml</relativePath> 
    </parent> 


    <build> 
     <plugins> 

      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>native-maven-plugin</artifactId> 
       <extensions>true</extensions> 
       <configuration> 
         <jdkIncludePath>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include</jdk IncludePath> 
        <javahOS>macosx</javahOS> 
        <javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory> 
        <!-- demonstrate we can override location of javah generate directory and use javah -o option instead" --> 
        <javahOutputFileName>posix-ipc.h</javahOutputFileName> 
        <javahClassNames> 
        <javahClassName>com.discovix.projects.glimmerglass.jni.posix.IPC</javahClassName> 
        </javahClassNames> 

        <compilerProvider>generic</compilerProvider> 
        <compilerStartOptions> 
         <compilerStartOption>-fPIC -O</compilerStartOption> 
        </compilerStartOptions> 
        <sources> 
         <source> 
          <directory>../src/main/native</directory> 
          <fileNames> 
           <fileName>ipc.cpp</fileName> 
          </fileNames> 
         </source> 
         <source> 
          <directory>/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/include/darwin</directory> 
          <includes> 
           <include>**/*.h</include> 
          </includes> 
         </source> 
        </sources> 

        <linkerStartOptions> 
         <linkerStartOption>-prebind -dynamiclib -lc -ldl</linkerStartOption> 
        </linkerStartOptions> 

       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

    <dependencies> 
     <dependency> 
      <groupId>com.discovix</groupId> 
      <artifactId>network-analyzer</artifactId> 
      <version>1.0-SNAPSHOT</version> 
      <type>jar</type> 
      <scope>compile</scope> 
     </dependency> 
    </dependencies> 
</project>