@ SuppressWarnings ( "static-method" ) protected Job createJobForMavenProject ( IProject project ) { return new Job ( Messages . EnableSarlMavenNatureAction_0 ) { @ Override protected IStatus run ( IProgressMonitor monitor ) { final SubMonitor mon = SubMonitor . convert ( monitor , 3 ) ; try { // The project should be a Maven project. final IPath descriptionFilename = project . getFile ( new Path ( IProjectDescription . DESCRIPTION_FILE_NAME ) ) . getLocation ( ) ; final File projectDescriptionFile = descriptionFilename . toFile ( ) ; final IPath classpathFilename = project . getFile ( new Path ( FILENAME_CLASSPATH ) ) . getLocation ( ) ; final File classpathFile = classpathFilename . toFile ( ) ; // Project was open by the super class. Close it because Maven fails when a project already exists. project . close ( mon . newChild ( 1 ) ) ; // Delete the Eclipse project and classpath definitions because Maven fails when a project already exists. project . delete ( false , true , mon . newChild ( 1 ) ) ; if ( projectDescriptionFile . exists ( ) ) { projectDescriptionFile . delete ( ) ; } if ( classpathFile . exists ( ) ) { classpathFile . delete ( ) ; } // Import MavenImportUtils . importMavenProject ( project . getWorkspace ( ) . getRoot ( ) , project . getName ( ) , true , mon . newChild ( 1 ) ) ; } catch ( CoreException exception ) { SARLMavenEclipsePlugin . getDefault ( ) . log ( exception ) ; } return Status . OK_STATUS ; } } ; }
Create the configuration job for a Maven project .