diff options
author | Szymon Ptaszkiewicz | 2012-03-29 23:18:18 -0400 |
---|---|---|
committer | Satyam Kandula | 2012-03-29 23:18:18 -0400 |
commit | 38d91f2a0d120c54f3563eb3ae4a819ad53edf06 (patch) | |
tree | 39a6f908d13d0b36b8a6f409cdb0e868e2f2a73d | |
parent | 6c7abe90183484d585c334aa10f32c5f8581b4a1 (diff) | |
download | eclipse.jdt.core-38d91f2a0d120c54f3563eb3ae4a819ad53edf06.zip eclipse.jdt.core-38d91f2a0d120c54f3563eb3ae4a819ad53edf06.tar.gz eclipse.jdt.core-38d91f2a0d120c54f3563eb3ae4a819ad53edf06.tar.xz |
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 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" |