blob: 3fbe7d1f3ccc3d25e63c4f1e14dba21839ab1911 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2014 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* The Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*
*******************************************************************************/
package org.eclipse.vorto.codegen.api.tasks;
import org.eclipse.vorto.codegen.api.IProjectGenerator;
import org.eclipse.vorto.codegen.api.tasks.eclipse.ClasspathConfiguration;
import org.eclipse.vorto.codegen.api.tasks.eclipse.ConfigurationContainer;
import org.eclipse.vorto.codegen.api.tasks.eclipse.IEclipseProjectConfiguration;
import org.eclipse.vorto.codegen.api.tasks.eclipse.EclipseProjectGenerator;
import org.eclipse.vorto.codegen.api.tasks.eclipse.FolderModule;
import org.eclipse.vorto.codegen.api.tasks.eclipse.LocationWrapper;
import org.eclipse.vorto.codegen.api.tasks.eclipse.MavenNatureConfiguration;
import org.eclipse.vorto.codegen.api.tasks.eclipse.NatureConfiguration;
import org.eclipse.vorto.codegen.api.tasks.ICodeGeneratorTask;
/**
* Creates a configuration for a Code Generator
*
*
*
*/
public class GeneratorConfiguration {
/**
* Creates a Generator Task for the Generation of an Eclipse Project.
* Returned generator can be executed with
* {@link IProjectGenerator#generate(org.eclipse.vorto.functionblock.FunctionblockModel, org.eclipse.core.runtime.IProgressMonitor)}
*
* Example: eclipseProject('myproject',configuration(mavenNature(new
* MyPomTemplate())),new MyCustomGeneratorTask(),
* MyOtherCustomGeneratorTask())
*
* @param projectName
* target eclipse project name
* @param configuration
* configurations for the project
* @param tasks
* custom code generation tasks
*
* @return fully configured eclipse project generator.
*/
public static IProjectGenerator eclipseProject(String projectName,
ConfigurationContainer configuration, ICodeGeneratorTask... tasks) {
return new EclipseProjectGenerator(projectName, configuration, tasks);
}
/**
* Creates a Generator Task for the Generation of an Eclipse Project.
* Returned generator can be executed with
* {@link IProjectGenerator#generate(org.eclipse.vorto.functionblock.FunctionblockModel, org.eclipse.core.runtime.IProgressMonitor)}
*
* Example: eclipseProject('myproject',configuration(mavenNature(new
* MyPomTemplate())),new MyCustomGeneratorTask(),
* MyOtherCustomGeneratorTask())
*
* @param location
* custom location specific setting for the target project
* @param configuration
* configurations for the project
* @param tasks
* custom code generation tasks
*
* @return fully configured eclipse project generator.
*/
public static IProjectGenerator eclipseProject(LocationWrapper location,
ConfigurationContainer configuration,
ICodeGeneratorTask... generators) {
return new EclipseProjectGenerator(location, configuration, generators);
}
/**
* Eclipse configurations for the project, like nature(s) or classpath
* variables etc.
*
* @param configurations
* a list of configurations
* @return
*/
public static ConfigurationContainer configuration(
IEclipseProjectConfiguration... configurations) {
return new ConfigurationContainer(configurations);
}
/**
* @return an empty configuration for a project.
*/
public static ConfigurationContainer empty() {
return new ConfigurationContainer();
}
/**
* Makes the eclipse project a java project
*
* @param configurations
* additional configurations for the java project
* @return
*/
public static IEclipseProjectConfiguration javaNature(
IEclipseProjectConfiguration... configurations) {
return new NatureConfiguration("org.eclipse.jdt.core.javanature",
configurations);
}
/**
* Makes the project a xText project
*
* @param configurations
* additional configurations for the xText project
* @return
*/
public static IEclipseProjectConfiguration xtextNature(
IEclipseProjectConfiguration... configurations) {
return new NatureConfiguration(
"org.eclipse.xtext.ui.shared.xtextNature", configurations);
}
/**
* Makes the project a Maven project
*
* @param pom
* maven build file template
* @param configurations
* additional configurations for the maven project
* @return
*/
public static IEclipseProjectConfiguration mavenNature(ITemplate pom,
IEclipseProjectConfiguration... configurations) {
return new MavenNatureConfiguration(pom, javaNature());
}
/**
* Creates the specified folder(s) for the eclipse project
*
* @param folders
* a list of folder names, like model or src-gen/model
* @return
*/
public static ICodeGeneratorTask folders(String... folders) {
return new FolderModule(folders);
}
/**
* Makes the specified folder(s) source folders for the project
*
* @param sourceFolders
* a list of folder names, like model or target/generated-sources
* @return
*/
public static IEclipseProjectConfiguration sourceFolders(
String... sourceFolders) {
return new ClasspathConfiguration(sourceFolders);
}
}