Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-04-05 22:02:21 +0000
committervladt2011-04-05 22:02:49 +0000
commit01631b1d7f0ff327426c24b541bc9f8ab0655616 (patch)
treec062986c3782b944a82427f20a4e99cf5f7b9359 /org.eclipse.m2e.jdt
parent71833b1c71a465c15f93a68f9705f42b18a43704 (diff)
downloadm2e-core-01631b1d7f0ff327426c24b541bc9f8ab0655616.tar.gz
m2e-core-01631b1d7f0ff327426c24b541bc9f8ab0655616.tar.xz
m2e-core-01631b1d7f0ff327426c24b541bc9f8ab0655616.zip
Moved the AbstractJavaProjectConfigurator class from m2e-extras to m2e-core/o.e.m2e.jdt
Diffstat (limited to 'org.eclipse.m2e.jdt')
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/AbstractJavaProjectConfigurator.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/AbstractJavaProjectConfigurator.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/AbstractJavaProjectConfigurator.java
new file mode 100644
index 00000000..fcfc9704
--- /dev/null
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/AbstractJavaProjectConfigurator.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Sonatype, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.m2e.jdt;
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+import org.eclipse.m2e.core.project.MavenProjectUtils;
+import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
+import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
+
+public abstract class AbstractJavaProjectConfigurator
+ extends AbstractProjectConfigurator
+ implements IJavaProjectConfigurator
+{
+ @Override
+ public void configure( ProjectConfigurationRequest request, IProgressMonitor monitor )
+ throws CoreException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void configureClasspath( IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor )
+ throws CoreException
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void configureRawClasspath( ProjectConfigurationRequest request, IClasspathDescriptor classpath,
+ IProgressMonitor monitor )
+ throws CoreException
+ {
+ IMavenProjectFacade facade = request.getMavenProjectFacade();
+
+ assertHasNature( request.getProject(), JavaCore.NATURE_ID );
+
+ for ( MojoExecution mojoExecution : getMojoExecutions( request, monitor ) )
+ {
+ File[] sources = getSourceFolders( request, mojoExecution );
+
+ for ( File source : sources )
+ {
+ IPath sourcePath = getFullPath( facade, source );
+
+ if ( sourcePath != null && !classpath.containsPath( sourcePath ) )
+ {
+ classpath.addSourceEntry( sourcePath, facade.getOutputLocation(), true );
+ }
+ }
+ }
+ }
+
+ protected IPath getFullPath( IMavenProjectFacade facade, File file )
+ {
+ IProject project = facade.getProject();
+ IPath path = MavenProjectUtils.getProjectRelativePath( project, file.getAbsolutePath() );
+ return project.getFullPath().append( path );
+ }
+
+ protected File[] getSourceFolders( ProjectConfigurationRequest request, MojoExecution mojoExecution )
+ throws CoreException
+ {
+ return new File[] { getParameterValue( getOutputFolderParameterName(), File.class, request.getMavenSession(),
+ mojoExecution ) };
+ }
+
+ protected String getOutputFolderParameterName()
+ {
+ return "outputDirectory";
+ }
+
+}

Back to the top