/**
 * Copyright 2019 Kyrill Zotkin
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.enterprisedomain.classmaker.core;

import java.util.Map;

import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.enterprisedomain.classmaker.ClassMakerService;
import org.enterprisedomain.classmaker.Contribution;
import org.enterprisedomain.classmaker.Project;
import org.osgi.framework.ServiceException;

public class ClassMakerBuilder extends IncrementalProjectBuilder implements IBuildConfiguration {

	public static final String BUILDER_ID = ClassMakerPlugin.BUILDER_ID;

	@Override
	public <T> T getAdapter(Class<T> adapter) {
		return null;
	}

	@Override
	public String getName() {
		return BUILDER_ID;
	}

	@Override
	protected IProject[] build(int kind, Map<String, String> options, IProgressMonitor monitor) throws CoreException {
		ClassMakerService service = null;
		try {
			service = ClassMakerPlugin.getClassMaker();
		} catch (ServiceException e) {
			return null;
		}
		if (service == null)
			return null;
		Project project = service.getWorkspace().getProject(getProject().getName());
		if (project instanceof Contribution && project.isDirty())
			((Contribution) project).build(monitor);
		return null;
	}

}

@@ -1881,16 +1881,18 @@
 Dirty())
+ %7B
 %0A%09%09%09((Co
@@ -1928,16 +1928,48 @@
 nitor);%0A
+%09%09%09project.setDirty(false);%0A%09%09%7D%0A
 %09%09return

Update builder for dirty