|
Lines 14-19
Link Here
|
| 14 |
import java.io.ByteArrayInputStream; |
14 |
import java.io.ByteArrayInputStream; |
| 15 |
import java.io.UnsupportedEncodingException; |
15 |
import java.io.UnsupportedEncodingException; |
| 16 |
import java.lang.reflect.InvocationTargetException; |
16 |
import java.lang.reflect.InvocationTargetException; |
|
|
17 |
import java.util.ArrayList; |
| 17 |
import java.util.Arrays; |
18 |
import java.util.Arrays; |
| 18 |
import java.util.List; |
19 |
import java.util.List; |
| 19 |
|
20 |
|
|
Lines 31-36
Link Here
|
| 31 |
import org.eclipse.jdt.core.IClasspathEntry; |
32 |
import org.eclipse.jdt.core.IClasspathEntry; |
| 32 |
import org.eclipse.jdt.core.IJavaProject; |
33 |
import org.eclipse.jdt.core.IJavaProject; |
| 33 |
import org.eclipse.jdt.core.JavaCore; |
34 |
import org.eclipse.jdt.core.JavaCore; |
|
|
35 |
import org.eclipse.jdt.core.JavaModelException; |
| 34 |
import org.eclipse.jem.util.logger.proxy.Logger; |
36 |
import org.eclipse.jem.util.logger.proxy.Logger; |
| 35 |
import org.eclipse.jst.common.project.facet.WtpUtils; |
37 |
import org.eclipse.jst.common.project.facet.WtpUtils; |
| 36 |
import org.eclipse.jst.common.project.facet.core.ClasspathHelper; |
38 |
import org.eclipse.jst.common.project.facet.core.ClasspathHelper; |
|
Lines 38-43
Link Here
|
| 38 |
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; |
40 |
import org.eclipse.jst.j2ee.internal.common.J2EEVersionUtil; |
| 39 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; |
41 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer; |
| 40 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; |
42 |
import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainerUtils; |
|
|
43 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; |
| 44 |
import org.eclipse.jst.j2ee.internal.plugin.J2EEPreferences; |
| 41 |
import org.eclipse.jst.j2ee.internal.web.classpath.WebAppLibrariesContainer; |
45 |
import org.eclipse.jst.j2ee.internal.web.classpath.WebAppLibrariesContainer; |
| 42 |
import org.eclipse.jst.j2ee.model.IModelProvider; |
46 |
import org.eclipse.jst.j2ee.model.IModelProvider; |
| 43 |
import org.eclipse.jst.j2ee.model.ModelProviderManager; |
47 |
import org.eclipse.jst.j2ee.model.ModelProviderManager; |
|
Lines 59-64
Link Here
|
| 59 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; |
63 |
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation; |
| 60 |
import org.eclipse.wst.common.project.facet.core.IDelegate; |
64 |
import org.eclipse.wst.common.project.facet.core.IDelegate; |
| 61 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
65 |
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; |
|
|
66 |
import org.eclipse.wst.project.facet.ProductManager; |
| 62 |
|
67 |
|
| 63 |
public final class WebFacetInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { |
68 |
public final class WebFacetInstallDelegate extends J2EEFacetInstallDelegate implements IDelegate { |
| 64 |
|
69 |
|
|
Lines 99-105
Link Here
|
| 99 |
|
104 |
|
| 100 |
String contextRoot = model.getStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT); |
105 |
String contextRoot = model.getStringProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT); |
| 101 |
setContextRootPropertyIfNeeded(c, contextRoot); |
106 |
setContextRootPropertyIfNeeded(c, contextRoot); |
| 102 |
setOutputFolder(model, c); |
107 |
//setOutputFolder(model, c); |
|
|
108 |
setJavaOutputPropertyIfNeeded(model, c); |
| 103 |
|
109 |
|
| 104 |
final IVirtualFolder webroot = c.getRootFolder(); |
110 |
final IVirtualFolder webroot = c.getRootFolder(); |
| 105 |
if (webroot.getProjectRelativePath().equals(new Path("/"))) //$NON-NLS-1$ |
111 |
if (webroot.getProjectRelativePath().equals(new Path("/"))) //$NON-NLS-1$ |
|
Lines 266-269
Link Here
|
| 266 |
} |
272 |
} |
| 267 |
} |
273 |
} |
| 268 |
} |
274 |
} |
|
|
275 |
|
| 276 |
private void setJavaOutputPropertyIfNeeded(IDataModel model, final IVirtualComponent c) { |
| 277 |
// Make sure output folder is set properly for web projects, and the product setting for single root structure is maintained. |
| 278 |
// We may need to change the existing setup |
| 279 |
|
| 280 |
if (ProductManager.shouldUseSingleRootStructure()) { |
| 281 |
String outputFolder = J2EEPlugin.getDefault().getJ2EEPreferences().getString(J2EEPreferences.Keys.DYN_WEB_OUTPUT_FOLDER); |
| 282 |
|
| 283 |
IJavaProject jproj = JavaCore.create(c.getProject()); |
| 284 |
IClasspathEntry[] current = null; |
| 285 |
boolean webinf = false; |
| 286 |
IPath pjpath = c.getProject().getFullPath(); |
| 287 |
try { |
| 288 |
current = jproj.getRawClasspath(); |
| 289 |
List updatedList = new ArrayList(); |
| 290 |
IPath sourcePath = null; |
| 291 |
boolean changeNeeded = false; |
| 292 |
for (int i = 0; i < current.length; i++) { |
| 293 |
IClasspathEntry entry = current[i]; |
| 294 |
if ((entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) && (entry.getOutputLocation() != null && entry.getOutputLocation().toString().indexOf(outputFolder) == -1)) { |
| 295 |
//output different than the preference value |
| 296 |
sourcePath = entry.getPath(); |
| 297 |
updatedList.add(JavaCore.newSourceEntry(sourcePath)); |
| 298 |
changeNeeded = true; |
| 299 |
} |
| 300 |
else |
| 301 |
updatedList.add(entry); |
| 302 |
} |
| 303 |
IPath currentDefaultOutput = null; |
| 304 |
currentDefaultOutput = jproj.getOutputLocation(); |
| 305 |
if (currentDefaultOutput.toString().indexOf(outputFolder) == -1) |
| 306 |
changeNeeded = true; |
| 307 |
if (changeNeeded) { |
| 308 |
IClasspathEntry[] updated = (IClasspathEntry[])updatedList.toArray(new IClasspathEntry[updatedList.size()]); |
| 309 |
IPath outdir = pjpath.append(outputFolder); |
| 310 |
jproj.setRawClasspath(updated,outdir ,null); |
| 311 |
jproj.save(null, true); |
| 312 |
} |
| 313 |
} catch (JavaModelException e) { |
| 314 |
Logger.getLogger().logError(e); |
| 315 |
} |
| 316 |
} |
| 317 |
// Now just set the property |
| 318 |
String existing = c.getMetaProperties().getProperty("java-output-path"); //$NON-NLS-1$ |
| 319 |
if (existing == null) |
| 320 |
setOutputFolder(model, c); |
| 321 |
} |
| 322 |
|
| 269 |
} |
323 |
} |