diff options
| author | Szymon Ptaszkiewicz | 2012-03-28 11:19:38 +0000 |
|---|---|---|
| committer | Satyam Kandula | 2012-03-28 11:19:38 +0000 |
| commit | 88aa1b709c25b8b1bf6b428540d305dd5a1a00d3 (patch) | |
| tree | b359cb0a816d1d078705614a5dd6f2e0902ad9c7 | |
| parent | 5540f6360e90e32ddf4acee0793dedac97444f45 (diff) | |
| download | eclipse.jdt.core-88aa1b709c25b8b1bf6b428540d305dd5a1a00d3.tar.gz eclipse.jdt.core-88aa1b709c25b8b1bf6b428540d305dd5a1a00d3.tar.xz eclipse.jdt.core-88aa1b709c25b8b1bf6b428540d305dd5a1a00d3.zip | |
Fix for 185601: .apt_generated is not restored as a source folder
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 8aba5a768e..4933b24e42 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 db553231cd..d580d9bc1e 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" |
