1 19 20 package org.netbeans.modules.j2ee.ejbjarproject.api; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.math.BigDecimal ; 25 import java.util.Stack ; 26 import org.netbeans.api.java.platform.JavaPlatform; 27 import org.netbeans.api.java.platform.JavaPlatformManager; 28 import org.netbeans.api.java.project.JavaProjectConstants; 29 import org.netbeans.modules.j2ee.deployment.devmodules.api.AntDeploymentHelper; 30 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; 31 import org.netbeans.modules.j2ee.ejbjarproject.*; 32 import org.netbeans.spi.project.support.ant.PropertyUtils; 33 import org.netbeans.spi.project.support.ant.ReferenceHelper; 34 import org.openide.ErrorManager; 35 import org.openide.filesystems.FileObject; 36 import org.openide.filesystems.FileStateInvalidException; 37 import org.openide.filesystems.FileUtil; 38 import org.openide.filesystems.Repository; 39 import org.netbeans.api.project.Project; 40 import org.netbeans.api.project.ProjectManager; 41 import org.netbeans.spi.project.support.ant.AntProjectHelper; 42 import org.netbeans.spi.project.support.ant.EditableProperties; 43 import org.netbeans.spi.project.support.ant.ProjectGenerator; 44 import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment; 45 import org.netbeans.modules.j2ee.dd.api.ejb.DDProvider; 46 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 47 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform; 48 import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.EjbJarProjectProperties; 49 import org.netbeans.modules.j2ee.ejbjarproject.ui.customizer.PlatformUiSupport; 50 import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants; 51 import org.openide.modules.SpecificationVersion; 52 import org.openide.util.Mutex; 53 import org.openide.util.MutexException; 54 import org.openide.util.NbBundle; 55 import org.w3c.dom.Document ; 56 import org.w3c.dom.Element ; 57 import org.w3c.dom.NodeList ; 58 59 65 public class EjbJarProjectGenerator { 66 67 private static final String DEFAULT_DOC_BASE_FOLDER = "conf"; private static final String DEFAULT_SRC_FOLDER = "src"; private static final String DEFAULT_TEST_FOLDER = "test"; private static final String DEFAULT_RESOURCE_FOLDER = "setup"; private static final String DEFAULT_JAVA_FOLDER = "java"; private static final String DEFAULT_BUILD_DIR = "build"; 74 public static final String MINIMUM_ANT_VERSION = "1.6"; 75 76 private EjbJarProjectGenerator() {} 77 78 85 public static AntProjectHelper createProject(File dir, String name, String j2eeLevel, String serverInstanceID) throws IOException { 86 FileObject fo = createProjectDir(dir); 87 88 FileObject srcRoot = fo.createFolder(DEFAULT_SRC_FOLDER); srcRoot.createFolder(DEFAULT_JAVA_FOLDER); FileObject testRoot = fo.createFolder(DEFAULT_TEST_FOLDER); 91 FileObject confRoot = srcRoot.createFolder(DEFAULT_DOC_BASE_FOLDER); 93 FileUtil.copyFile(Repository.getDefault().getDefaultFileSystem().findResource("org-netbeans-modules-j2ee-ejbjarproject/MANIFEST.MF"), confRoot, "MANIFEST"); 96 AntProjectHelper h = setupProject (fo, name, "src", "test", null, null, null, j2eeLevel, serverInstanceID); 97 EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 98 ep.put (EjbJarProjectProperties.SOURCE_ROOT, DEFAULT_SRC_FOLDER); ep.setProperty(EjbJarProjectProperties.META_INF, "${"+EjbJarProjectProperties.SOURCE_ROOT+"}/"+DEFAULT_DOC_BASE_FOLDER); ep.setProperty(EjbJarProjectProperties.SRC_DIR, "${"+EjbJarProjectProperties.SOURCE_ROOT+"}/"+DEFAULT_JAVA_FOLDER); ep.setProperty(EjbJarProjectProperties.META_INF_EXCLUDES, "sun-cmp-mappings.xml"); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 103 104 Project p = ProjectManager.getDefault().findProject(h.getProjectDirectory ()); 105 ProjectManager.getDefault().saveProject(p); 106 107 if (!J2eeModule.JAVA_EE_5.equals(j2eeLevel)) { 109 String resource = "org-netbeans-modules-j2ee-ejbjarproject/ejb-jar-2.1.xml"; 110 FileObject ddFile = FileUtil.copyFile(Repository.getDefault().getDefaultFileSystem().findResource(resource), confRoot, "ejb-jar"); EjbJar ejbJar = DDProvider.getDefault().getMergedDDRoot( 112 org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(ddFile).getMetadataUnit()); 113 ejbJar.setDisplayName(name); 114 ejbJar.write(ddFile); 115 } 116 117 return h; 118 } 119 120 137 public static AntProjectHelper importProject(final File dir, final String name, 138 final File [] sourceFolders, final File [] testFolders, 139 final File configFilesBase, final File libFolder, final String j2eeLevel, 140 String serverInstanceID, boolean fromJavaSources) throws IOException { 141 142 AntProjectHelper retVal = importProject(dir,name,sourceFolders,testFolders, 143 configFilesBase,libFolder,j2eeLevel,serverInstanceID); 144 EditableProperties subEp = retVal.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 145 subEp.setProperty(EjbJarProjectProperties.JAVA_SOURCE_BASED,fromJavaSources+""); retVal.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,subEp); 147 Project subP = ProjectManager.getDefault().findProject(retVal.getProjectDirectory()); 148 ProjectManager.getDefault().saveProject(subP); 149 return retVal; 150 } 151 152 public static AntProjectHelper importProject(final File dir, final String name, 153 final File [] sourceFolders, final File [] testFolders, 154 final File configFilesBase, final File libFolder, final String j2eeLevel, String serverInstanceID) throws IOException { 155 assert sourceFolders != null && testFolders != null: "Package roots can't be null"; final FileObject dirFO = createProjectDir (dir); 157 final AntProjectHelper h = setupProject(dirFO, name, null, null, 159 configFilesBase, (libFolder == null ? null : libFolder), null, j2eeLevel, serverInstanceID); 160 final EjbJarProject p = (EjbJarProject) ProjectManager.getDefault().findProject(dirFO); 161 final ReferenceHelper refHelper = p.getReferenceHelper(); 162 try { 163 ProjectManager.mutex().writeAccess( new Mutex.ExceptionAction () { 164 public Object run() throws Exception { 165 Element data = h.getPrimaryConfigurationData(true); 166 Document doc = data.getOwnerDocument(); 167 NodeList nl = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); 168 assert nl.getLength() == 1; 169 Element sourceRoots = (Element ) nl.item(0); 170 nl = data.getElementsByTagNameNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); assert nl.getLength() == 1; 172 Element testRoots = (Element ) nl.item(0); 173 for (int i=0; i<sourceFolders.length; i++) { 174 String propName = "src.dir" + (i == 0 ? "" : Integer.toString (i+1)); String srcReference = refHelper.createForeignFileReference(sourceFolders[i], JavaProjectConstants.SOURCES_TYPE_JAVA); 176 Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); root.setAttribute ("id",propName); sourceRoots.appendChild(root); 179 EditableProperties props = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 180 props.put(propName,srcReference); 181 h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); } 183 184 if (testFolders.length == 0) { 185 String testLoc = NbBundle.getMessage (EjbJarProjectGenerator.class,"TXT_DefaultTestFolderName"); 186 File f = new File (dir,testLoc); 187 f.mkdirs(); 188 String propName = "test.src.dir"; 189 Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); root.setAttribute ("id",propName); root.setAttribute ("name",NbBundle.getMessage(EjbJarProjectGenerator.class, "NAME_test.src.dir")); 192 testRoots.appendChild(root); 193 EditableProperties props = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 194 props.put(propName,testLoc); 195 h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); } 197 else { 198 for (int i=0; i<testFolders.length; i++) { 199 if (!testFolders[i].exists()) { 200 testFolders[i].mkdirs(); 201 } 202 String propName = "test.src.dir" + (i == 0 ? "" : Integer.toString (i+1)); String testReference = refHelper.createForeignFileReference(testFolders[i], JavaProjectConstants.SOURCES_TYPE_JAVA); 204 Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); root.setAttribute ("id",propName); testRoots.appendChild(root); 207 EditableProperties props = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); props.put(propName,testReference); 209 h.putProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH, props); 210 } 211 } 212 h.putPrimaryConfigurationData(data,true); 213 ProjectManager.getDefault().saveProject (p); 214 return null; 215 } 216 }); 217 } catch (MutexException me ) { 218 ErrorManager.getDefault().notify (me); 219 } 220 FileObject ejbJarXml = FileUtil.toFileObject(configFilesBase).getFileObject("ejb-jar.xml"); if (ejbJarXml != null) { 223 try { 224 EjbJar root = DDProvider.getDefault().getMergedDDRoot( 225 org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(ejbJarXml).getMetadataUnit()); 226 boolean writeDD = false; 227 if (new BigDecimal (EjbJar.VERSION_2_0).equals(root.getVersion()) && j2eeLevel.equals(EjbJarProjectProperties.J2EE_1_4)) { root.setVersion(new BigDecimal (EjbJar.VERSION_2_1)); 229 writeDD = true; 230 } 231 String dispName = root.getDefaultDisplayName(); 233 if (null == dispName || dispName.trim().length() == 0) { 234 root.setDisplayName(name); 235 writeDD = true; 236 } 237 if (writeDD) 238 root.write(ejbJarXml); 239 } 240 catch (IOException e) { 241 ErrorManager.getDefault().notify(e); 242 } 243 } 244 return h; 245 } 246 247 private static String createFileReference(ReferenceHelper refHelper, FileObject projectFO, FileObject referencedFO) { 248 if (FileUtil.isParentOf(projectFO, referencedFO)) { 249 return relativePath(projectFO, referencedFO); 250 } else { 251 return refHelper.createForeignFileReference(FileUtil.toFile(referencedFO), null); 252 } 253 } 254 255 private static String relativePath (FileObject parent, FileObject child) { 256 if (child.equals (parent)) 257 return ""; 258 if (!FileUtil.isParentOf (parent, child)) 259 throw new IllegalArgumentException ("Cannot find relative path, " + parent + " is not parent of " + child); 260 return child.getPath ().substring (parent.getPath ().length () + 1); 261 } 262 263 private static AntProjectHelper setupProject (FileObject dirFO, String name, 264 String srcRoot, String testRoot, File configFiles, File libraries, String resources, 265 String j2eeLevel, String serverInstanceID) throws IOException { 266 AntProjectHelper h = ProjectGenerator.createProject(dirFO, EjbJarProjectType.TYPE); 267 final EjbJarProject prj = (EjbJarProject) ProjectManager.getDefault().findProject(h.getProjectDirectory()); 268 final ReferenceHelper referenceHelper = prj.getReferenceHelper(); 269 Element data = h.getPrimaryConfigurationData(true); 270 Document doc = data.getOwnerDocument(); 271 Element nameEl = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name"); nameEl.appendChild(doc.createTextNode(name)); 273 data.appendChild(nameEl); 274 Element minant = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); minant.appendChild(doc.createTextNode(MINIMUM_ANT_VERSION)); 276 data.appendChild(minant); 277 278 282 EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 283 Element sourceRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots"); if (srcRoot != null) { 285 Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); root.setAttribute ("id","src.dir"); root.setAttribute ("name",NbBundle.getMessage(EjbJarProjectGenerator.class, "NAME_src.dir")); 288 sourceRoots.appendChild(root); 289 ep.setProperty("src.dir", srcRoot); } 291 data.appendChild (sourceRoots); 292 Element testRoots = doc.createElementNS(EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"test-roots"); if (testRoot != null) { 294 Element root = doc.createElementNS (EjbJarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"root"); root.setAttribute ("id","test.src.dir"); root.setAttribute ("name",NbBundle.getMessage(EjbJarProjectGenerator.class, "NAME_test.src.dir")); 297 testRoots.appendChild (root); 298 ep.setProperty("test.src.dir", testRoot); } 300 data.appendChild (testRoots); 301 h.putPrimaryConfigurationData(data, true); 302 303 if (resources != null) { 304 ep.setProperty(EjbJarProjectProperties.RESOURCE_DIR, resources); 305 } else { 306 ep.setProperty(EjbJarProjectProperties.RESOURCE_DIR, DEFAULT_RESOURCE_FOLDER); 307 } 308 309 JavaPlatform defaultPlatform = JavaPlatformManager.getDefault().getDefaultPlatform(); 310 SpecificationVersion v = defaultPlatform.getSpecification().getVersion(); 311 String sourceLevel = v.toString(); 312 if (sourceLevel.equals("1.6") || sourceLevel.equals("1.7")) 314 sourceLevel = "1.5"; 315 ep.setProperty(EjbJarProjectProperties.JAVAC_SOURCE, sourceLevel); ep.setProperty(EjbJarProjectProperties.JAVAC_TARGET, sourceLevel); 318 ep.setProperty(EjbJarProjectProperties.JAVAC_CLASSPATH, ""); 319 320 ep.setProperty(EjbJarProjectProperties.DIST_DIR, "dist"); 321 ep.setProperty(EjbJarProjectProperties.DIST_JAR, "${"+EjbJarProjectProperties.DIST_DIR+"}/" + "${" + EjbJarProjectProperties.JAR_NAME + "}"); 322 ep.setProperty(EjbJarProjectProperties.DIST_EAR_JAR, "${"+EjbJarProjectProperties.DIST_DIR+"}/" + "${" + EjbJarProjectProperties.JAR_NAME + "}"); 324 ep.setProperty(EjbJarProjectProperties.J2EE_PLATFORM, j2eeLevel); 325 ep.setProperty(EjbJarProjectProperties.JAR_NAME, PropertyUtils.getUsablePropertyName(name) + ".jar"); 326 ep.setProperty(EjbJarProjectProperties.JAR_COMPRESS, "false"); 327 329 Deployment deployment = Deployment.getDefault (); 330 ep.setProperty(EjbJarProjectProperties.J2EE_SERVER_TYPE, deployment.getServerID (serverInstanceID)); 331 ep.setProperty(EjbJarProjectProperties.JAVAC_DEBUG, "true"); 332 ep.setProperty(EjbJarProjectProperties.JAVAC_DEPRECATION, "false"); 333 334 ep.setProperty(EjbJarProjectProperties.JAVAC_TEST_CLASSPATH, new String [] { 335 "${javac.classpath}:", "${build.classes.dir}:", "${libs.junit.classpath}", }); 339 ep.setProperty(EjbJarProjectProperties.RUN_TEST_CLASSPATH, new String [] { 340 "${javac.test.classpath}:", "${build.test.classes.dir}", }); 343 ep.setProperty(EjbJarProjectProperties.DEBUG_TEST_CLASSPATH, new String [] { 344 "${run.test.classpath}", }); 346 347 ep.setProperty(EjbJarProjectProperties.BUILD_DIR, DEFAULT_BUILD_DIR); 348 ep.setProperty(EjbJarProjectProperties.BUILD_TEST_CLASSES_DIR, "${build.dir}/test/classes"); ep.setProperty(EjbJarProjectProperties.BUILD_TEST_RESULTS_DIR, "${build.dir}/test/results"); ep.setProperty(EjbJarProjectProperties.BUILD_GENERATED_DIR, "${"+EjbJarProjectProperties.BUILD_DIR+"}/generated"); 351 ep.setProperty(EjbJarProjectProperties.BUILD_CLASSES_DIR, "${"+EjbJarProjectProperties.BUILD_DIR+"}/jar"); 352 ep.setProperty(EjbJarProjectProperties.BUILD_EAR_CLASSES_DIR, "${"+EjbJarProjectProperties.BUILD_DIR+"}/ear-module"); 353 ep.setProperty(EjbJarProjectProperties.BUILD_CLASSES_EXCLUDES, "**/*.java,**/*.form,**/.nbattrs"); 354 ep.setProperty(EjbJarProjectProperties.DIST_JAVADOC_DIR, "${"+EjbJarProjectProperties.DIST_DIR+"}/javadoc"); 355 ep.setProperty(EjbJarProjectProperties.JAVA_PLATFORM, "default_platform"); 356 ep.setProperty(EjbJarProjectProperties.DEBUG_CLASSPATH, "${"+EjbJarProjectProperties.JAVAC_CLASSPATH+"}:${"+EjbJarProjectProperties.BUILD_CLASSES_DIR+"}"); 357 ep.setProperty(EjbJarProjectProperties.JAVADOC_PRIVATE, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_NO_TREE, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_USE, "true"); ep.setProperty(EjbJarProjectProperties.JAVADOC_NO_NAVBAR, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_NO_INDEX, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_SPLIT_INDEX, "true"); ep.setProperty(EjbJarProjectProperties.JAVADOC_AUTHOR, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_VERSION, "false"); ep.setProperty(EjbJarProjectProperties.JAVADOC_WINDOW_TITLE, ""); ep.setProperty(EjbJarProjectProperties.JAVADOC_ENCODING, ""); ep.setProperty(EjbJarProjectProperties.JAVADOC_PREVIEW, "true"); ep.setProperty(EjbJarProjectProperties.JAVADOC_ADDITIONALPARAM, ""); 370 h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 371 372 if (configFiles != null) { 373 String ref = createFileReference(referenceHelper, dirFO, FileUtil.toFileObject(configFiles)); 374 EditableProperties props = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 375 props.setProperty(EjbJarProjectProperties.META_INF, ref); 376 h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); 377 } 378 if (libraries != null) { 379 String ref = createFileReference(referenceHelper, dirFO, FileUtil.toFileObject(libraries)); 380 EditableProperties props = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 381 props.setProperty(EjbJarProjectProperties.LIBRARIES_DIR, ref); 382 h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); 383 } 384 385 ep = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH); 386 ep.setProperty(EjbJarProjectProperties.J2EE_SERVER_INSTANCE, serverInstanceID); 387 388 J2eePlatform j2eePlatform = Deployment.getDefault().getJ2eePlatform(serverInstanceID); 390 if (!j2eePlatform.getSupportedSpecVersions(J2eeModule.EJB).contains(j2eeLevel)) { 391 ErrorManager.getDefault().log(ErrorManager.WARNING, "J2EE level:" + j2eeLevel + " not supported by server " + Deployment.getDefault().getServerInstanceDisplayName(serverInstanceID) + " for module type EJB"); 392 } 393 String classpath = Utils.toClasspathString(j2eePlatform.getClasspathEntries()); 394 ep.setProperty(EjbJarProjectProperties.J2EE_PLATFORM_CLASSPATH, classpath); 395 396 if (j2eePlatform.isToolSupported(J2eePlatform.TOOL_WSCOMPILE)) { 398 File [] wsClasspath = j2eePlatform.getToolClasspathEntries(J2eePlatform.TOOL_WSCOMPILE); 399 ep.setProperty(WebServicesConstants.J2EE_PLATFORM_WSCOMPILE_CLASSPATH, 400 Utils.toClasspathString(wsClasspath)); 401 } 402 403 File projectFolder = FileUtil.toFile(dirFO); 405 try { 406 AntDeploymentHelper.writeDeploymentScript(new File (projectFolder, EjbJarProjectProperties.ANT_DEPLOY_BUILD_SCRIPT), 407 J2eeModule.EJB, serverInstanceID); 408 } catch (IOException ioe) { 409 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe); 410 } 411 File deployAntPropsFile = AntDeploymentHelper.getDeploymentPropertiesFile(serverInstanceID); 412 if (deployAntPropsFile != null) { 413 ep.setProperty(EjbJarProjectProperties.DEPLOY_ANT_PROPS_FILE, deployAntPropsFile.getAbsolutePath()); 414 } 415 416 h.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep); 417 Project p = ProjectManager.getDefault().findProject(dirFO); 418 ProjectManager.getDefault().saveProject(p); 419 return h; 420 } 421 422 private static FileObject createProjectDir (File dir) throws IOException { 423 Stack stack = new Stack (); 424 while (!dir.exists()) { 425 stack.push (dir.getName()); 426 dir = dir.getParentFile(); 427 } 428 FileObject dirFO = FileUtil.toFileObject (dir); 429 if (dirFO == null) { 430 refreshFileSystem(dir); 431 dirFO = FileUtil.toFileObject (dir); 432 } 433 assert dirFO != null; 434 while (!stack.isEmpty()) { 435 dirFO = dirFO.createFolder((String )stack.pop()); 436 } 437 return dirFO; 438 } 439 440 private static void refreshFileSystem (final File dir) throws FileStateInvalidException { 441 File rootF = dir; 442 while (rootF.getParentFile() != null) { 443 rootF = rootF.getParentFile(); 444 } 445 FileObject dirFO = FileUtil.toFileObject(rootF); 446 assert dirFO != null : "At least disk roots must be mounted! " + rootF; dirFO.getFileSystem().refresh(false); 448 } 449 450 public static void setPlatform(final AntProjectHelper helper, final String platformName, final String sourceLevel) { 453 ProjectManager.mutex().writeAccess(new Runnable () { 454 public void run() { 455 try { 456 EjbJarProject project = (EjbJarProject)ProjectManager.getDefault().findProject(helper.getProjectDirectory()); 457 UpdateHelper updateHelper = project.getUpdateHelper(); 458 EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH); 459 String finalPlatformName = platformName; 460 if (finalPlatformName == null) 461 finalPlatformName = JavaPlatformManager.getDefault().getDefaultPlatform().getDisplayName(); 462 463 String srcLevel = sourceLevel; 465 if (sourceLevel.equals("1.6") || sourceLevel.equals("1.7")) 466 srcLevel = "1.5"; 467 PlatformUiSupport.storePlatform(ep, updateHelper, finalPlatformName, srcLevel != null ? new SpecificationVersion(srcLevel) : null); 468 helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep); 469 ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(helper.getProjectDirectory())); 470 } 471 catch (IOException e) { 472 ErrorManager.getDefault().notify(e); 473 } 474 } 475 }); 476 } 477 } 478 | Popular Tags |