2013-08-01 48 views
4

我正在創建一些需要第三方插件和功能的Eclipse插件和功能。爲了將這些依賴包括到我的項目中,我創建了一個p2佈局存儲庫。使用tycho指向本地p2存儲庫構建本地eclipse插件

注意:我的p2工件不是Maven項目......但是,我使用的是Maven風格的建築。下面是P2庫

<properties> 
    <tycho-version>0.18.0</tycho-version> 
    </properties> 

    <repositories> 
     <repository> 
       <id>eclipse-platform-m6</id> 
       <layout>p2</layout> 
       <url>http://download.eclipse.org/eclipse/updates/3.8</url> 
     </repository> 
    </repositories> 

    <build> 
    <plugins> 
     <plugin> 
      <groupId>org.eclipse.tycho.extras</groupId> 
      <artifactId>tycho-p2-extras-plugin</artifactId> 
      <version>${tycho-version}</version> 
      <executions> 
       <execution> 
        <phase>prepare-package</phase> 
        <goals> 
         <goal>publish-features-and-bundles</goal> 
        </goals> 
        <configuration> 
         <compress>false</compress> 
         <artifactRepositoryLocation>/mypath/target/repository</artifactRepositoryLocation> 
         <metadataRepositoryLocation>/mypath/target/repository</metadataRepositoryLocation> 
         <sourceLocation>/mypath/src</sourceLocation> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.eclipse.tycho</groupId> 
      <artifactId>tycho-p2-repository-plugin</artifactId> 
      <version>${tycho-version}</version> 
      <configuration> 
      </configuration> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>verify-repository</goal> 
         <goal>archive-repository</goal> 
        </goals> 
        <configuration> 
         <compress>false</compress> 
         <includeAllDependencies>true</includeAllDependencies> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.eclipse.tycho</groupId> 
      <artifactId>tycho-p2-publisher-plugin</artifactId> 
      <version>${tycho-version}</version> 
      <configuration> 
      <publishArtifacts>true</publishArtifacts> 
      </configuration> 
     </plugin> 
     <plugin><!-- enable the Tycho build extension --> 
      <groupId>org.eclipse.tycho</groupId> 
      <artifactId>tycho-maven-plugin</artifactId> 
      <version>${tycho-version}</version> 
      <extensions>true</extensions> 
     </plugin> 
    </plugins> 
    </build> 

pom.xml中上面的成功生成,並創建(和驗證)在P2存儲庫。我得到我的target/目錄中的項目

- Project 
    .. 
    .. 
    - target 
     - p2agent 
     - org.eclipse.equinox.p2.core 
     - org.eclipse.equinox.p2.engine 
     - repository 
     - features 
     - plugins 
      artifacts.xml 
      content.xml 
     <projectname>-<version>.zip <!-- This contains same things as repository directory here --> 

的結構如下現在,我用第谷建立我的插件和功能部件,並參考我上面創建的P2存儲庫。我有以下爲我的插件項目的結構和特徵

- bundle.parent 
    - bundle.mainplugin 
    - bundle.mainplugin.test.fragment 
    - bundle.mainplugin.feature 

這裏是我的bundle.parent的pom.xml

<repositories> 
     <repository> 
       <id>eclipse-platform-m6</id> 
       <layout>p2</layout> 
       <url>http://download.eclipse.org/eclipse/updates/3.8</url> 
     </repository> 
     <repository> 
       <id>third-party-eclipse-plugins</id> 
       <layout>p2</layout> 
       <url>file:///.../target/repository</url> 
     </repository> 
    </repositories> 
    <modules> 
    <module>../bundle.mainplugin</module> 
    <module>../bundle.mainplugin.test.fragment</module> 
    <module>../bundle.mainplugin.feature</module> 
    </modules> 
    <build> 
    <plugins> 
    <plugin> 
     <groupId>org.eclipse.tycho</groupId> 
     <artifactId>tycho-maven-plugin</artifactId> 
     <version>${tycho-version}</version> 
     <extensions>true</extensions> 
    </plugin> 
    </plugins> 
</build> 

最後,我運行父pom.xml的目標mvn clean install。不幸的是,當我的插件中的類擴展插件中的某些類時,mvn-compile會引發編譯問題。 (這些類在運行時也是必需的)。以下是錯誤:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.18.0:compile (default-compile 
) on project <Project Name>: Compilation failure 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) 
    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:320) 
    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:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    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: copied.org.apache.maven.plugin.CompilationFailureException: Compilation failure 
    at copied.org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:442) 
    at org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo.execute(AbstractOsgiCompilerMojo.java:239) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
    ... 19 more 

我的問題:

從編譯器錯誤,我相信第谷是有點不使這些提供給我的班其中有一個編譯器錯誤第三方文物。有沒有辦法確定我的插件類是否存在於Tycho類路徑中?

UPDATE

,我想在第谷反應堆提供this location

java -jar /home/.../eclipse-3.8.2/plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -debug -consolelog -application org.eclipse.equinox.p2.director -repository file:///home/../target/repository -list 

所有第三方捆綁第三方束經過可用性出現了成功。

+0

'file:///.../ target/repository' URL不起作用。一個解決方案可能是Laurents的答案或[這個其他問題](http://stackoverflow.com/questions/4344961/tool-for-managing-hosting-own-p2-repositories)。我不知道你如何進入編譯步驟。我假設依賴解析已經失敗。 – oberlies

+0

我已關閉該項目,並且無法再訪問代碼以測試解決方案 – Vikram

回答

0

只需更換:

<url>file:///.../target/repository</url> 

由:

<url>file:<projectname>/deploy/target/repository</url> 

(如果你的父母pom.xml的是你的根文件夾)

+0

感謝您的評論。我已經離開了我正在爲之工作的項目,並且無法嘗試您的建議。 – Vikram

1

的人誰也運行到這個問題,你可以也嘗試使用:

${project.basedir} 

所以,說你有以下目錄:

- projects: 
    - main-project 
    - local-repository 

在父POM(即:主項目/ POM。xml)使用相對路徑引用本地存儲庫,方法如下:

<url>file:${project.basedir}/target/repository</url> 
+1

文件:$ {project.basedir}在Windows系統上產生無效的URL。改用$ {project.baseUri}。 – oberlies

+0

如果您的p2 repo不在您的項目的子目錄中,請在Linux中嘗試' file:$ {user.home}/somewhere/target/repository'。 –

3

Sebastian Zarnekow的回答給了我一個提示。

Error while building an xtext project with ant: Generation of the Grammar classes fails

你可以從錯誤信息推斷,行家無法從注入創造語言模型。究其原因,在上面的鏈接解釋說:

Xtext uses the platform:/resource URI scheme of EMF.

解決的辦法是你需要給EMFGenerator的,其中型號目錄應該是一個新的聲明。在**。mwe2文件,將以下代碼

fragment = ecore.EMFGeneratorFragment auto-inject {} 

fragment = ecore.EMFGeneratorFragment auto-inject { 
    javaModelDirectory = "/${projectName}/src-gen" 
} 

應該做的伎倆。

+0

這只是拯救了我的夜晚! Tycho/Maven/Xtext的構建方式令人困惑,謝謝你的訣竅。 –

相關問題