2014-04-01 35 views
0

現在,本地人的路徑與工作區相關。Eclipse項目相對於本地人的路徑

這是一件壞事,因爲當有人使用git連接到它並以不同的方式命名項目時,路徑將無法工作。我希望他們是相對於項目文件夾,不管它的名字。

如果您有任何想法來實現這一點,請提出建議。

爲了說明,這裏有一個.classpath

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 

    <classpathentry kind="lib" path="lib/lwjgl.jar" sourcepath="lib"> 
     <attributes> 
      <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Rogue/lib"/> 
     </attributes> 
    </classpathentry> 

    <classpathentry kind="output" path="bin"/> 
</classpath> 

回答

0

的關鍵在這裏取得成功,是你不要的.classpath添加到GIT。 相反,你把它放在Git忽略。

這些文件中有一些是您不想要的版本控制系統。

例如在.gitignore文件以

.* 
!.gitignore 
*~ 
.svn/ 
# Windows image file caches 
Thumbs.db 
ehthumbs.db 

# Folder config file 
Desktop.ini 

# Recycle Bin used on file shares 
$RECYCLE.BIN/ 

*~ 
\#*\# 
/.emacs.desktop 
/.emacs.desktop.lock 
.elc 
auto-save-list 
tramp 
.\#* 

# Org-mode 
.org-id-locations 
*_archive 

*.pydevproject 
.project 
.metadata 
bin/** 
tmp/** 
tmp/**/* 
*.tmp 
*.bak 
*.swp 
*~.nib 
local.properties 
.classpath 
.settings/ 
.loadpath 

# External tool builders 
.externalToolBuilders/ 

# Locally stored "Eclipse launch configurations" 
*.launch 

# CDT-specific 
.cproject 

# PDT-specific 
.buildpath 

target/ 
*~ 
*.log 
logs/ 
*.iml 
+0

好吧,我想你是對的。然而,問題在於用所有本機和源代碼創建一個合適的.classpath是相當繁瑣的,但它可能確實不應該在git中。 – MightyPork

+0

那麼你的問題的答案很簡單。 - 不要這樣做! 讓IDE生成.classpath文件。 Eclipse處理該任務真的很好。 這會讓你的工作變得更簡單。 所有你需要做的就是以正確的方式導入項目。 – Viggo