List of usage examples for org.aspectj.ajde.core AjCompiler build
public void build()
From source file:org.eclipse.ajdt.core.builder.AJBuilder.java
License:Open Source License
protected IProject[] build(int kind, Map args, IProgressMonitor progressMonitor) throws CoreException { IProject project = getProject();//from ww w. jav a 2 s . c om AjCompiler compiler = AspectJPlugin.getDefault().getCompilerFactory().getCompilerForProject(project); CoreCompilerConfiguration compilerConfig = (CoreCompilerConfiguration) compiler.getCompilerConfiguration(); // 100 ticks for the compiler, 1 for the pre-build actions, 1 for the post-build actions progressMonitor.beginTask(CoreMessages.builder_taskname, 102); AJLog.logStart(TimerLogEvent.TIME_IN_BUILD); AJLog.logStart("Pre compile"); AJLog.log(AJLog.BUILDER, "==========================================================================================="); //$NON-NLS-1$ AJLog.log(AJLog.BUILDER, "Build kind = " + buildKindString(kind)); //$NON-NLS-1$ IProject[] requiredProjects = getRequiredProjects(project, true); // perform all pre-build actions CompilationParticipant[] participants = prebuild(kind, project, requiredProjects, compilerConfig); progressMonitor.worked(1); String mode = ""; //$NON-NLS-1$ if (kind != IncrementalProjectBuilder.FULL_BUILD) { mode = "Incremental AspectJ compilation"; //$NON-NLS-1$ } else { mode = "Full AspectJ compilation"; //$NON-NLS-1$ } AJLog.log(AJLog.BUILDER, "Project=" //$NON-NLS-1$ + project.getName() + ", kind of build requested=" + mode); //$NON-NLS-1$ // bug 270554 augment the aspect path with builder arguments augmentAspectPath(project, args); if (!isWorthBuilding(project)) { postBuild(kind, true, participants, compiler); AJLog.log(AJLog.BUILDER, "build: Abort due to missing classpath/inpath/aspectpath entries"); //$NON-NLS-1$ AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD); progressMonitor.done(); return requiredProjects; } // workaround for bug 73435 IProject[] dependingProjects = getDependingProjects(project); IJavaProject javaProject = JavaCore.create(project); if (!javaProject.hasBuildState() && dependingProjects.length > 0) { updateJavaCompilerPreferences(dependingProjects); } // end of workaround AJLog.logStart("Flush included source file cache"); // Flush the list of included source files stored for this project BuildConfig.flushIncludedSourceFileCache(project); AJLog.logEnd(AJLog.BUILDER, "Flush included source file cache"); AJLog.logStart("Check delta"); // Check the delta - we only want to proceed if something relevant // in this project has changed (a .java file, a .aj file or a // .lst file) IResourceDelta delta = getDelta(getProject()); // copy over any new resources (bug 78579) if (delta != null) { copyResources(javaProject, delta); } AJLog.logEnd(AJLog.BUILDER, "Check delta"); if (kind != FULL_BUILD) { AJLog.logStart("Look for source/resource changes"); if (!hasChangesAndMark(delta, project)) { AJLog.log(AJLog.BUILDER, "build: Examined delta - no source file or classpath changes for project " //$NON-NLS-1$ + project.getName()); // if the source files of any projects which the current // project depends on have changed, then need // also to build the current project boolean continueToBuild = false; for (int i = 0; !continueToBuild && i < requiredProjects.length; i++) { IResourceDelta otherProjDelta = getDelta(requiredProjects[i]); continueToBuild = otherProjDelta != null && (hasChangesAndMark(otherProjDelta, requiredProjects[i])); } // no changes found! end the compilation. if (!continueToBuild) { // bug 107027 compilerConfig.flushClasspathCache(); compilerConfig.configurationRead(); // reset config postBuild(kind, true, participants, compiler); AJLog.logEnd(AJLog.BUILDER, "Look for source/resource changes"); AJLog.log(AJLog.BUILDER, "No source/resource changes found, exiting build"); AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD); progressMonitor.done(); return requiredProjects; } } AJLog.logEnd(AJLog.BUILDER, "Look for source/resource changes"); } migrateToRTContainerIfNecessary(javaProject); IAJCompilerMonitor compilerMonitor = (IAJCompilerMonitor) compiler.getBuildProgressMonitor(); // Bug 43711 must do a clean and rebuild if we can't // find a buildConfig file from a previous compilation if (kind == FULL_BUILD || !hasValidPreviousBuildConfig(compiler.getId())) { cleanOutputFolders(javaProject, false); AJProjectModelFactory.getInstance().removeModelForProject(project); copyResources(javaProject); } else { // doing an incremental build if (AspectJCorePreferences.isIncrementalCompilationOptimizationsEnabled()) { // Bug 245566: // facilitate incremental compilation by checking // classpath for projects that have changed since the last build long timestamp = getLastBuildTimeStamp(compiler); compilerConfig.setClasspathElementsWithModifiedContents(getChangedRequiredProjects(timestamp)); } } // bug 270335 -- if output locations have changed, then // need a new output location manager. compilerConfig.flushOutputLocationManagerIfNecessary(kind); compilerConfig.buildStarting(); compilerMonitor.prepare(new SubProgressMonitor(progressMonitor, 100)); AJLog.log(AJLog.BUILDER_CLASSPATH, "Classpath = " + compilerConfig.getClasspath()); //$NON-NLS-1$ AJLog.logEnd(AJLog.BUILDER, "Pre compile"); // ---------------------------------------- // Do the compilation AJLog.logStart(TimerLogEvent.TIME_IN_AJDE); if (kind == FULL_BUILD) { compiler.buildFresh(); } else { compiler.build(); } AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_AJDE); // compilation is done // ---------------------------------------- doRefreshAfterBuild(project, dependingProjects, javaProject); // do the cleanup // bug 107027 compilerConfig.flushClasspathCache(); postBuild(kind, false, participants, compiler); progressMonitor.worked(1); progressMonitor.done(); AJLog.logEnd(AJLog.BUILDER, TimerLogEvent.TIME_IN_BUILD); return requiredProjects; }