aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-03-30 09:22:39 (EDT)
committerSatyam Kandula2012-03-30 09:22:39 (EDT)
commit1a5efc64260aebe5aa230fe401b873f78f03bc3e (patch)
treeb839b19c545f1f8f914019732e7944ed4cfede5e
parent91c408a3b01a8fe5d9c54cec3b4171166cf448e0 (diff)
downloadeclipse.jdt.core-1a5efc64260aebe5aa230fe401b873f78f03bc3e.zip
eclipse.jdt.core-1a5efc64260aebe5aa230fe401b873f78f03bc3e.tar.gz
eclipse.jdt.core-1a5efc64260aebe5aa230fe401b873f78f03bc3e.tar.bz2
Fix for 185601: .apt_generated is not restored as a source folder
-rw-r--r--org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java13
-rw-r--r--org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java15
2 files changed, 18 insertions, 10 deletions
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java
index 8aba5a7..4933b24 100644
--- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java
+++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/generatedfile/GeneratedSourceFolderManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 BEA Systems, Inc.
+ * Copyright (c) 2005, 2012 BEA Systems, Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* wharley@bea.com - initial API and implementation
+ * IBM Corporation - modified to fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=185601
*******************************************************************************/
package org.eclipse.jdt.apt.core.internal.generatedfile;
@@ -51,6 +52,10 @@ import org.eclipse.jdt.core.JavaModelException;
* the enabled/disabled state or the folder name change. These changes are
* discovered via the preferenceChanged() method.
* <p>
+ * We attempt to update the classpath with an entry for the generated source
+ * folder if APT is enabled and there is no entry for this folder present
+ * on the classpath.
+ * <p>
* GeneratedSourceFolderManager is responsible only for the folder itself, not
* its contents. Contents are managed by @see GeneratedFileManager.
*
@@ -161,7 +166,9 @@ public class GeneratedSourceFolderManager {
/**
* Creates the generated source folder if necessary. This should be called just
* before doing a build.
- * No changes to the classpath will be made.
+ *
+ * Classpath will be updated with an entry for the generated source folder
+ * if it is not already added to the classpath. See bug 185601.
*/
public void ensureFolderExists(){
// If APT is disabled, do nothing.
@@ -182,7 +189,7 @@ public class GeneratedSourceFolderManager {
}
if (createOnDisk(srcFolder)) {
- if (isOnClasspath(srcFolder)) {
+ if (addToClasspath(srcFolder)) {
synchronized (this) {
// Only set _generatedSourceFolder if folder is on disk and on classpath.
_generatedSourceFolder = srcFolder;
diff --git a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
index db55323..d580d9b 100644
--- a/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
+++ b/org.eclipse.jdt.apt.tests/src/org/eclipse/jdt/apt/tests/AptBuilderTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 BEA Systems, Inc.
+ * Copyright (c) 2005, 2012 BEA Systems, Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* mkaufman@bea.com - initial API and implementation
- *
+ * IBM Corporation - updated test to reflect changes for https://bugs.eclipse.org/bugs/show_bug.cgi?id=185601
*******************************************************************************/
package org.eclipse.jdt.apt.tests;
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.apt.core.internal.AptPlugin;
import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager;
import org.eclipse.jdt.apt.core.util.AptConfig;
-import org.eclipse.jdt.apt.core.util.AptPreferenceConstants;
import org.eclipse.jdt.apt.tests.annotations.helloworld.HelloWorldAnnotationProcessor;
import org.eclipse.jdt.apt.tests.annotations.messager.MessagerAnnotationProcessor;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -625,6 +624,9 @@ public class AptBuilderTests extends APTTestBase
expectingNoProblems();
}
+ // After fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=185601,
+ // the config marker 'Generated source folder * is not in classpath'
+ // is not easy to simulate. So, this test doesn't really do anything
public void testConfigMarker() throws Exception{
final String projectName = "ConfigMarkerTestProject";
final IJavaProject javaProj = createJavaProject( projectName );
@@ -651,10 +653,9 @@ public class AptBuilderTests extends APTTestBase
javaProj.setRawClasspath(cp, null);
fullBuild( project.getFullPath() );
expectingNoProblems();
- // make sure we post the marker about the incorrect classpath
- expectingMarkers(new String[]{"Generated source folder '" +
- AptPreferenceConstants.DEFAULT_GENERATED_SOURCE_FOLDER_NAME +
- "' is missing from classpath"} );
+ // classpath should be updated with an entry for the source folder
+ // make sure we do not post the marker about the incorrect classpath
+ expectingNoMarkers();
// take out the annotation and no type generation will occur.
code = "package pkg;\n"