2014-02-13 91 views
6

我知道還有很多關於這個主題的其他問題,我已經搜索並閱讀了所有內容,但即使這些問題目前還沒有幫助。Maven遠程資源插件問題

共享資源的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> 
    <parent> 
     <groupId>com.myorganization</groupId> 
     <artifactId>myapp</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>myapp-resources</artifactId> 
    <name>Resources Bundle</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-remote-resources-plugin</artifactId> 
       <version>1.5</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>bundle</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins>  
    </build> 
</project> 

它基本上是說:拿起你的資源目錄所擁有的一切,和它確實是,所有的資源,最終在罐子的根文件。與remote-resources.xml也放在罐子下的META-INF/manifest目錄下。所以,一切似乎都很好,並根據預期。

現在,其他,更難,不工作的一部分。 POM文件爲模塊使用共享資源的摘錄上述

<plugin> 
       <artifactId>maven-remote-resources-plugin</artifactId> 
       <version>1.5</version> 
       <executions> 
        <execution> 
         <id>process-remote-resources</id> 
         <goals> 
          <goal>process</goal> 
         </goals> 
         <configuration> 
          <resourceBundles> 
           <resourceBundle>com.myorganization:myapp-resources:1.0-SNAPSHOT</resourceBundle> 
          </resourceBundles> 
          <outputdirectory>${project.build.directory}/shared-resources</outputdirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 

所以,在這裏它說指定處理來自資源包的資源,並把它們在共享資源目錄。但是,沒有任何反應。當我嘗試執行mvn remote-resources:process時,我收到錯誤消息,說明resourceBundles的參數丟失或無效。如果我運行mvn install沒有錯誤,但是當我嘗試複製(maven資源插件)shared-resources目錄中的任何內容時,它只是跳過它作爲不存在的資源目錄。

此外,我試圖把錯誤的名稱爲resourceBundle,並給我一個即時的錯誤,它不存在,所以我敢肯定,我指定了resourceBundle正確。

任何人都可以啓發我嗎?什麼做錯了?謝謝。

編輯: 添加聚甲醛的部分來引用共享資源dependecy

<dependency> 
      <groupId>com.myorganization</groupId> 
      <artifactId>myapp-resources</artifactId> 
      <version>1.0-SNAPSHOT</version> 
     </dependency> 

EDIT2: 添加包含共享資源罐子內遠程resources.xml中的含量:

<?xml version="1.0" encoding="UTF-8"?> 
<remoteResourcesBundle xsi:schemaLocation="http://maven.apache.org/remote-resources/1.1.0 http://maven.apache.org/xsd/remote-resources-1.1.0.xsd" 
    xmlns="http://maven.apache.org/remote-resources/1.1.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <sourceEncoding>UTF-8</sourceEncoding> 
</remoteResourcesBundle> 

這個是否應該像這樣是空的(除了源編碼設置)?

EDIT3: 我已經採取了看看用於remote-resource.xml XSD架構,似乎這不應該是空的,但是包含在這個過程中目標所使用的遠程資源的列表。這意味着這個文件不能正確生成。

EDIT4: 執行mvn remote-resources:process當安裝拋出的錯誤:

The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process (default-cli) on project lte-troubleshoting-solution: The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220) 
     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:317) 
     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152) 
     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) 
     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) 
     at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) 
     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:606) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 
     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'resourceBundles' for goal org.apache.maven.plugins:maven-remote-resources-plugin:1.5:process are missing or invalid 
     at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:581) 
     at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:534) 
     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:97) 
     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 
     ... 19 more 

什麼也很有趣,似乎在插件配置的outputDirectory設置沒有,因爲在所有的調試回升日誌我可以看到outputDirectory設置被設置爲默認值。

回答

9

我終於找到了解決辦法。問題實際上是我必須在pom配置中明確指定包含remote-resources.xml正確生成,並在流程目標的稍後部分中包含remote-resource.xml中列出的所有資源。

因此,對於共享資源模塊的最終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> 
    <parent> 
     <groupId>com.myorganization</groupId> 
     <artifactId>myapp</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <artifactId>myapp-resources</artifactId> 
    <name>Resources Bundle</name> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-remote-resources-plugin</artifactId> 
       <version>1.5</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>bundle</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <includes> 
         <include>**/*.*</include> 
        </includes> 
       </configuration> 
      </plugin> 
     </plugins>  
    </build> 
</project> 

附加說明 似乎outputDirectoryprocess目標有沒有影響,資源在插件中指定的默認路徑上解包。

1

檢查插件here的文檔,我看不到任何明顯的錯誤。

這意味着com.myorganization:myapp-resources:1.0-SNAPSHOT必須錯誤/破壞。

確保您在本地回購中確實存在此依賴關係。如果您沒有它,請確保Maven可以從某處下載或在本地安裝。

+0

我已經列爲依賴在POM配置和沒有抱怨。那個特定的jar安裝在我的本地倉庫中。我將編輯我的原始帖子以添加該部分。 – htomek

+0

你能否添加確切的錯誤信息?還要看看在這之前是否可以找到任何其他錯誤(也許這是後續問題)。最後,嘗試用'-X'運行Maven以獲得調試輸出。也許這將包含一些有用的信息。 –