2

I am developing a Bukkit plugin with the M2E plugin in Eclipse. I have a problem where the maven dependency (Bukkit 1.5.2 R1.0) is in two different locations depending on whether I am at school or not. At home the file tree is in my dropbox with the maven repo at C:/users/canon/.m2/repository/org/bukkit/bukkit-1.5.2-R1.0 but at school it is located at C:/users/nmeyer/.m2/repository/org/bukkit/bukkit-1.5.2-R1.0. I have been able to recreate the project with maven such that the maven repository is in the correct place on only one computer at a time, but not both at once. Is there a way that I can tell Maven to look in both these file locations for the maven repository so I do not have to keep identical versions of the same project configured for one or the other locations only?

Additional Note: whichever file path I create the maven project with will work and display correctly with the bukkit-1.5.2-R1.0 jar file tree correctly displayed under maven dependencies, but it will not work on a computer in the other location (home vs school).

Clarification: The Maven repository is defined in my pom.xml but i don't see where to find the maven repo path. I've attached my pom.xml because the format of it seems to be a little different than the posted possible answers took into account:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nathanMeyer</groupId>
<artifactId>headInfo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
            <source>1.7</source>
            <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>bukkit-repo</id>
        <url> http://repo.bukkit.org/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>org.bukkit</groupId>
        <artifactId>bukkit</artifactId>
        <version>1.5.2-R1.0</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>
</dependencies> 

Nathan Meyer
  • 409
  • 1
  • 6
  • 13
  • Maybe you can create the directory from school in your home computer so it is the same path. Or you try to (sym)link that maybe. – xdevs23 Apr 11 '16 at 18:41
  • Dont sync the .classpath file between your computers, this contains computer local settings. – Ferrybig Apr 11 '16 at 20:30

2 Answers2

1

For Maven, you don't need to hard-code paths. You can use:

${user.home}

For example,

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>false</offline>
  ...
</settings>

Review the maven settings reference for more info: https://maven.apache.org/settings.html

Your import, then, would look something like this:

<plugin>
    <groupId>org.bukkit</groupId>
    <artifactId>bukkit-1.5.2-R1.0</artifactId>
</plugin>
Christopher Schneider
  • 3,745
  • 2
  • 24
  • 38
0

I figured out what the problem is, and it's so stupid that i didn't even think of it originally. Turns out that my school blocks bukkit.org as "games" and since school computer Eclipse hasn't had a chance to connect to that repository from the school computer since the repo http://repo.bukkit.org/content/groups/public/ was inaccessable.

Nathan Meyer
  • 409
  • 1
  • 6
  • 13