问题
I'm using Eclipse on a small development environment where one developer has a Windows PC and the other has a MacBook. We share code using a subversion repository, and use Maven as an "External Tool" (not using the m2e plugin).
We each have an M2_REPO variable that has been working great for resolving paths to .jar files on our two systems. Recently, however, I ran a command to tell Maven to pull down sources and javadocs.
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
Since then, I see some very Windows-centric references in my .classpath that are a nuissance to my Mac-using friend.
<classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar"
sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4-sources.jar">
<attributes>
<attribute value="jar:file:/C:/Users/John/.m2/repository/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4-javadoc.jar!/" name="javadoc_location"/>
</attributes>
</classpathentry>
Even after having removed the downloadSources and downloadJavadocs parameters, and verified that they're false in my plugin configuration for maven-eclipse-plugin, deleted my .classpath file, and reran mvn eclipse:eclipse
I still see those unwanted references placed into my .classpath file.
Has anyone found a good working solution to this problem? Have I overlooked some setting that tells Maven to use the M2_REPO variable in its references to javadoc files?
回答1:
On my team we don't commit Eclipse .settings
or .classpath
files into source control. When we initially check out projects we use m2e to build the classpath (did it with eclipse goal as you are once upon a time) and everything is set up correctly no matter what platform the developer is using. We have people using Win 7, Macs, and various Linux flavors and the build machine is Linux, no issues I know of anywhere.
回答2:
I don't use maven, I am the only developer and I have a Windows PC and a Mac. For me this "small" solution works fine. Create a symbolik link so your paths on both systems match:
C:\> mklink /d "C:\Users\xxx\android-sdks" "C:\Users\xxx\AppData\Local\Android\android-sdk"
I did this on the windows machine. The command is mklink /d (for directory) newDir existingDir. Works on Windows 7 at least. Maybe this will help.
回答3:
Try enabling the dependency management of your maven project by:
Right Click on the project –> Maven –> Enable Dependency Management
After this delete and recreate your .classpath file.
回答4:
Rather than use 'mvn eclipse:eclipse', install M2Eclipse either from the project site or through the Eclipse Marketplace. It will handle all the linkups for you, and not embed absolute paths.
(I always version .classpath and .settings/)
回答5:
If you have javadocs in your repository, the maven eclipse plugin will always add them to your classpath.
The -DdownloadJavadocs=true option only tells the eclipse plugin to download them. It does not tell the plugin to include them or not in your classpath. If you do not want them in your classpath anymore, you have to remove all -javadoc. from your local repository (or delete your locate repository).
来源:https://stackoverflow.com/questions/10500745/wrestling-with-eclipse-modified-classpath-in-a-mixed-windows-mac-team-environme