diff options
author | Jesse Garms | 2005-11-03 18:20:02 +0000 |
---|---|---|
committer | Jesse Garms | 2005-11-03 18:20:02 +0000 |
commit | 50c8fc7c21507137e2b63d15c742a120cb954eef (patch) | |
tree | 4e698098c0ef81310a17e0f6505f17c605504449 /org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java | |
parent | f1d83e37dc72ba6d2676594fd1c64161817b3d74 (diff) | |
download | eclipse.jdt.core-50c8fc7c21507137e2b63d15c742a120cb954eef.tar.gz eclipse.jdt.core-50c8fc7c21507137e2b63d15c742a120cb954eef.tar.xz eclipse.jdt.core-50c8fc7c21507137e2b63d15c742a120cb954eef.zip |
jgarms: Switch to using a custom classloader so that we can close jars just before a project is deleted.
Diffstat (limited to 'org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java')
-rw-r--r-- | org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java index 11dcf12823..fcbbf61404 100644 --- a/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java +++ b/org.eclipse.jdt.apt.core/src/org/eclipse/jdt/apt/core/internal/AptCompilationParticipant.java @@ -127,35 +127,44 @@ public class AptCompilationParticipant implements ICompilationParticipant // If we're in batch mode, we need to reset the classloaders // for the batch processors before we begin boolean isFullBuild = pbce.isFullBuild(); - if (isFullBuild && pbce.getRound() == 0) { - AnnotationProcessorFactoryLoader.getLoader().resetBatchProcessors(pbce.getJavaProject()); - _previousRoundsBatchFactories.clear(); + try { + if (isFullBuild && pbce.getRound() == 0) { + AnnotationProcessorFactoryLoader.getLoader().resetBatchProcessors(pbce.getJavaProject()); + _previousRoundsBatchFactories.clear(); + } + + Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories = + AnnotationProcessorFactoryLoader.getLoader().getFactoriesAndAttributesForProject(javaProject); + + APTResult result = APTDispatch.runAPTDuringBuild(factories, _previousRoundsBatchFactories, buildFiles, javaProject, isFullBuild); + Set<IFile> newFiles = result.getNewFiles(); + Set<IFile> deletedFiles = new HashSet<IFile>(); + _previousRoundsBatchFactories.addAll(result.getDispatchedBatchFactory()); + + // see if APT updated a project's source path + boolean sourcePathChanged = result.getSourcePathChanged(); + + // for apt, new files will always trump deleted files + for ( IFile df : result.getDeletedFiles() ){ + if ( !newFiles.contains( df ) ){ + deletedFiles.add(df); + } + } + + return new PreBuildCompilationResult( + newFiles.toArray( new IFile[ newFiles.size() ] ), + deletedFiles.toArray( new IFile[ deletedFiles.size() ] ), + result.getNewDependencies(), + result.getProblems(), + sourcePathChanged ); } - - Map<AnnotationProcessorFactory, FactoryPath.Attributes> factories = - AnnotationProcessorFactoryLoader.getLoader().getFactoriesAndAttributesForProject(javaProject); - - APTResult result = APTDispatch.runAPTDuringBuild(factories, _previousRoundsBatchFactories, buildFiles, javaProject, isFullBuild); - Set<IFile> newFiles = result.getNewFiles(); - Set<IFile> deletedFiles = new HashSet<IFile>(); - _previousRoundsBatchFactories.addAll(result.getDispatchedBatchFactory()); - - // see if APT updated a project's source path - boolean sourcePathChanged = result.getSourcePathChanged(); - - // for apt, new files will always trump deleted files - for ( IFile df : result.getDeletedFiles() ){ - if ( !newFiles.contains( df ) ){ - deletedFiles.add(df); + finally { + if (isFullBuild) { + // In order to keep from locking jars, we explicitly close any batch-based + // classloaders we opened + AnnotationProcessorFactoryLoader.getLoader().closeBatchClassLoader(); } } - - return new PreBuildCompilationResult( - newFiles.toArray( new IFile[ newFiles.size() ] ), - deletedFiles.toArray( new IFile[ deletedFiles.size() ] ), - result.getNewDependencies(), - result.getProblems(), - sourcePathChanged ); } /** |