3737import org .gradle .api .plugins .JavaPlugin ;
3838import org .gradle .api .plugins .JavaPluginExtension ;
3939import org .gradle .api .provider .Provider ;
40+ import org .gradle .api .tasks .Delete ;
4041import org .gradle .api .tasks .Sync ;
4142import org .gradle .plugins .ide .eclipse .EclipsePlugin ;
4243import org .gradle .plugins .ide .eclipse .GenerateEclipseClasspath ;
@@ -153,6 +154,15 @@ private void configureEclipseIdeSettings(Project project, String eclipseJavaVers
153154 task .dependsOn (luceneEclipseJdt );
154155 });
155156
157+ var wipePreviousConfiguration =
158+ tasks .register (
159+ "wipePreviousConfiguration" ,
160+ Delete .class ,
161+ task -> {
162+ Path rootDir = getProjectRootPath (project );
163+ task .delete (rootDir .resolve (".classpath" ), rootDir .resolve (".project" ));
164+ });
165+
156166 // Add gradle plugin portal to the source repository list and
157167 // apply any ecj source repository hackery the same way as everywhere.
158168 project .getRepositories ().gradlePluginPortal ();
@@ -163,6 +173,8 @@ private void configureEclipseIdeSettings(Project project, String eclipseJavaVers
163173 .named ("eclipseClasspath" )
164174 .configure (
165175 task -> {
176+ task .dependsOn (wipePreviousConfiguration );
177+
166178 var classpath = task .getClasspath ();
167179 classpath .setDefaultOutputDir (project .file ("build/eclipse" ));
168180 classpath .setDownloadJavadoc (false );
0 commit comments