如何在 Eclipse 中为 Java 构建 Github API?

How do I build a Github API for Java, in Eclipse?

我正在尝试在 Eclipse 中为 Java 构建 Github API。 我从 link https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core 下载项目并按照自述文件中关于使用 pom/xml 文件构建的说明进行操作。 然后我按照描述执行 maven 的命令,但出现错误。

自述文件中的 Maven 命令是:

建筑物

GitHub Java API 是使用 Apache Maven 构建的。

运行 以下命令构建一个 JAR 文件,其中包含 GitHub Java API 而没有依赖项:

$ mvn -f pom-jar.xml clean install

一体机

GitHub Java API 也可以构建为包含所有依赖项的 JAR (Google Gson)。此技术使用 Maven Shade 插件构建一体化 JAR 文件。

$ mvn -f pom-jar.xml clean install -P shade

当我执行 maven 命令 $ mvn package 或自述文件中描述的命令时会发生这种情况。

C:\Users\panagiotis\Desktop\egit-github-master>mvn package
[INFO] Scanning for projects...
[INFO] Computing target platform for MavenProject: org.eclipse.mylyn.github:org.eclipse.egit.github.core:4.2.0-SNAPSHOT @ C:\Users\panagiotis\Desktop\egit-github-master\org.eclipse.egit.github.core\pom.xml
[INFO] Adding repository file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository
[ERROR] Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'egit' from location file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository: No repository found at file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository. -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'egit' from location file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        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: java.lang.RuntimeException: Failed to load p2 repository with ID 'egit' from location file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.loadMetadataRepository(TargetPlatformFactoryImpl.java:301)
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.gatherExternalInstallableUnits(TargetPlatformFactoryImpl.java:269)
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:174)
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:126)
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:1)
        at org.eclipse.tycho.p2.manager.ReactorRepositoryManagerImpl.computePreliminaryTargetPlatform(ReactorRepositoryManagerImpl.java:82)
        at org.eclipse.tycho.p2.resolver.P2DependencyResolver.computePreliminaryTargetPlatform(P2DependencyResolver.java:221)
        at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:109)
        at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:77)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:266)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        ... 11 more
Caused by: org.eclipse.equinox.p2.core.ProvisionException: No repository found at file:/C:/Users/panagiotis/Desktop/egit-github-master/org.eclipse.egit.github.core/../../egit/org.eclipse.egit.repository/target/repository.
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.fail(AbstractRepositoryManager.java:395)
        at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:692)
        at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
        at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:59)
        at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:52)
        at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.loadMetadataRepository(TargetPlatformFactoryImpl.java:297)
        ... 22 more
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException

我是第一次使用Maven,所以我找不到问题所在。 也许我必须将 egit-github-master 文件夹移动到其他特定目录中,或者我使用了错误的命令来构建?

您需要克隆 these 3 repositories 并基本上导入所有包含的 eclipse 项目:

  • jgit
  • egit
  • egit-github

您构建无法解析目标平台项目,该项目是 egit 存储库的一部分。您应该阅读完整的 egit contributor guide,因为在构建成功之前需要对 IDE 进行更多设置。