@@ -209,6 +209,7 @@ public static boolean hasJavaBuilder(IProject project) {
209209 }
210210
211211 public static boolean removeJavaBuilder (IProject project ) {
212+ boolean removed = false ;
212213 try {
213214 IProjectDescription description = project .getDescription ();
214215 ICommand [] commands = description .getBuildSpec ();
@@ -219,12 +220,32 @@ public static boolean removeJavaBuilder(IProject project) {
219220 System .arraycopy (commands , i + 1 , newCommands , i , commands .length - i - 1 );
220221 description .setBuildSpec (newCommands );
221222 project .setDescription (description , null );
222- return true ;
223+ removed = true ;
224+ break ;
225+ }
226+ }
227+ if (removed ) { // remove java2script builder, so later the builder can be the first builder
228+ for (int i = 0 ; i < commands .length ; ++i ) {
229+ if (commands [i ].getBuilderName ().equals ("net.sf.j2s.core.java2scriptbuilder" )) {
230+ ICommand [] newCommands = new ICommand [commands .length - 1 ];
231+ System .arraycopy (commands , 0 , newCommands , 0 , i );
232+ System .arraycopy (commands , i + 1 , newCommands , i , commands .length - i - 1 );
233+ description .setBuildSpec (newCommands );
234+ project .setDescription (description , null );
235+ break ;
236+ }
223237 }
224238 }
225239 } catch (CoreException e ) {
226240 e .printStackTrace ();
227241 }
228- return false ;
242+ Java2ScriptProjectNature pn = new Java2ScriptProjectNature ();
243+ pn .setProject (project );
244+ try {
245+ pn .configure ();
246+ } catch (CoreException e ) {
247+ e .printStackTrace ();
248+ }
249+ return removed ;
229250 }
230251}
0 commit comments