Index: src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java (revision 463128) +++ src/main/java/org/apache/maven/plugin/eclipse/AddMavenRepoMojo.java (working copy) @@ -62,6 +62,16 @@ public static final String CLASSPATH_VARIABLE_M2_REPO = "org.eclipse.jdt.core.classpathVariable.M2_REPO"; //$NON-NLS-1$ /** + * File that stores the Eclipse m2eclipse preferences. + */ + public static final String FILE_ECLIPSE_M2ECLIPSE_PREFS = "org.maven.ide.eclipse.prefs"; //$NON-NLS-1$ + + /** + * Property constant under which local repository setting is stored. + */ + public static final String M2_SETTING_LOCAL_REPOSITORY_DIRECTORY = "eclipse.m2.localRepositoryDirectory"; //$NON-NLS-1$ + + /** * Location of the Eclipse workspace that holds your * configuration and source. On Windows, this will be the * workspace directory under your eclipse installation. For @@ -80,16 +90,12 @@ */ private ArtifactRepository localRepository; - public void execute() - throws MojoExecutionException + private void addRespositoryPropertyToFile( File workDir, String fileName, String propertyName ) + throws MojoExecutionException { - - File workDir = new File( workspace, DIR_ECLIPSE_CORE_RUNTIME_SETTINGS ); - workDir.mkdirs(); - Properties props = new Properties(); - File f = new File( workDir, FILE_ECLIPSE_JDT_CORE_PREFS ); + File f = new File( workDir, fileName ); // preserve old settings if ( f.exists() ) @@ -110,7 +116,7 @@ } } - props.put( CLASSPATH_VARIABLE_M2_REPO, localRepository.getBasedir() ); //$NON-NLS-1$ //$NON-NLS-2$ + props.put( propertyName, localRepository.getBasedir() ); //$NON-NLS-1$ //$NON-NLS-2$ try { @@ -124,7 +130,18 @@ f.getAbsolutePath() ) ); } } + + public void execute() + throws MojoExecutionException + { + File workDir = new File( workspace, DIR_ECLIPSE_CORE_RUNTIME_SETTINGS ); + workDir.mkdirs(); + + addRespositoryPropertyToFile( workDir, FILE_ECLIPSE_JDT_CORE_PREFS, CLASSPATH_VARIABLE_M2_REPO ); + addRespositoryPropertyToFile( workDir, FILE_ECLIPSE_M2ECLIPSE_PREFS, M2_SETTING_LOCAL_REPOSITORY_DIRECTORY ); + } + public ArtifactRepository getLocalRepository() { return localRepository;