简体   繁体   English

在Eclipse中创建新项目,然后将其添加到Mercurial存储库中

[英]Creating new project in Eclipse then adding it to a Mercurial repo

I have access to an existing Mercurial repo located at merc.myorg.com/hghome . 我可以访问位于merc.myorg.com/hghome的现有Mercurial merc.myorg.com/hghome I have been asked to whip up a simple Java tool and commit it to the repo under hghome/myapp . 我被要求启动一个简单的Java工具,并将其提交到hghome/myapp下的hghome/myapp I have never used Mercurial before, and would like to accomplish the following: 我以前从未使用过Mercurial,并且想要完成以下任务:

  • Write the code in Eclipse 在Eclipse中编写代码
  • Use the MercurialEclipse plugin to get the sourcecode ( myapp ) up under hghome 使用MercurialEclipse插件在hghome下获取源代码( myapp

My first thought was to write all the code in an Eclipse project, and then try to connect to hghome somehow and push/copy all the code up to the server at the desired location. 我首先想到的是在Eclipse项目中编写所有代码,然后尝试以某种方式连接到hghome并将所有代码推送/复制到所需位置的服务器。 But then I figured that I probably can't push code to a repo/sub-repo ( hghome/myapp ) that doesn't exist yet. 但是后来我发现我可能无法将代码推送到尚不存在的repo / sub-repo( hghome/myapp )中。 So it feels like a chicken-and-the-egg sort of problem. 因此,这感觉就像是鸡到蛋的问题。

Let's pretend that myapp is a simple (Eclipse) Java project with the following directory structure: 让我们假设myapp是一个简单的(Eclipse)Java项目,具有以下目录结构:

myapp/
    src/main/java/ (Source Folder)
        com.myorg.myapp (Package)
            MyApp.java
    build.xml

I have already installed Mercurial and the MercurialEclipse plugin. 我已经安装了Mercurial和MercurialEclipse插件。 What are the exact steps I need to take to accomplish writing this, and getting it checked into a new repo at hghome/myapp ? 我需要采取什么确切的步骤来完成此操作,并将其检入hghome/myapp的新存储库中?

If I understand correctly you want to have an Eclipse project in a sub directory of a larger repository. 如果我理解正确,则希望在更大的存储库的子目录中有一个Eclipse项目。 I think there is no reason for you to use "subrepositores", instead you can use the single monolithic repository. 我认为没有理由使用“子存储库”,而是可以使用单个整体存储库。

  1. Using MercurialEclipse or another tool clone merc.myorg.com/hghome 使用MercurialEclipse或其他工具克隆merc.myorg.com/hghome
  2. Create the sub directory myapp and in it create an file with the name ".project" 创建子目录myapp,并在其中创建名称为“ .project”的文件
  3. In ".project" add appropriate Eclipse project configuration. 在“ .project”中,添加适当的Eclipse项目配置。 For example <projectDescription><name>myapp</name>[...]</projectDescription> . 例如<projectDescription><name>myapp</name>[...]</projectDescription>
  4. Commit ".project" and push it to the central server. 提交“ .project”并将其推送到中央服务器。
  5. Using MercurialEclipse clone merc.myorg.com/hghome again. 再次使用MercurialEclipse克隆merc.myorg.com/hghome。 This time on the last page it will allow you to import "myapp" as a project. 这次在最后一页上,您可以将“ myapp”作为项目导入。 It will show up in your workspace as an empty project. 它将作为一个空项目显示在您的工作区中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM