blob: a7064dadf73ec55aaa7134f746f609d78b773122 [file] [log] [blame]
/**
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*/
package org.eclipse.osbp.xtext.i18n;
import static com.google.common.collect.Sets.newHashSet;
import java.util.Set;
import org.eclipse.xtext.Constants;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IOutputConfigurationProvider;
import org.eclipse.xtext.generator.OutputConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.name.Named;
public class DSLOutputConfigurationProvider implements IOutputConfigurationProvider {
@Inject
@Named(Constants.FILE_EXTENSIONS)
private String extensions;
private static final Logger LOGGER = LoggerFactory.getLogger(DSLOutputConfigurationProvider.class);
public static final String SMOOKS_OUTPUT_ONCE = "DEFAULT_OUTPUT_ONCE";
public static final String SMOOKS_OUTPUT_DIRECTORY = "smooks";
public static final String DEFAULT_OUTPUT_I18N = "DEFAULT_OUTPUT_I18N";
public static final String I18N_OUTPUT_DIRECTORY = "i18n";
public static final String DEFAULT_REPORT_OUTPUT = "DEFAULT_REPORT_OUTPUT";
public static final String CUBE_CATALOG_OUTPUT = "CUBE_CATALOG_OUTPUT";
public static final String CUBE_CATALOG_DIRECTORY = "catalog";
public static final String CONFIGURATION_DIRECTORY = "config";
public static final boolean NAMEDDEFAULTDIRECTORY = false;
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
Set<OutputConfiguration> configs = newHashSet();
OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
defaultOutput.setDescription("Output Folder");
if(!NAMEDDEFAULTDIRECTORY || extensions == null) {
defaultOutput.setOutputDirectory("./src-gen");
} else {
defaultOutput.setOutputDirectory("./src-"+extensions);
}
defaultOutput.setOverrideExistingResources(true);
defaultOutput.setCreateOutputDirectory(true);
defaultOutput.setCleanUpDerivedResources(true);
defaultOutput.setSetDerivedProperty(true);
defaultOutput.setKeepLocalHistory(true);
configs.add(defaultOutput);
// LOGGER.debug("default:{}", defaultOutput);
OutputConfiguration onceOutput = new OutputConfiguration(SMOOKS_OUTPUT_ONCE);
onceOutput.setDescription("Output Folder (once)");
onceOutput.setOutputDirectory("./"+SMOOKS_OUTPUT_DIRECTORY);
onceOutput.setOverrideExistingResources(true);
onceOutput.setCreateOutputDirectory(true);
onceOutput.setCleanUpDerivedResources(true);
onceOutput.setSetDerivedProperty(true);
configs.add(onceOutput);
// LOGGER.debug("smooks:{}", onceOutput);
OutputConfiguration catalogOutput = new OutputConfiguration(CUBE_CATALOG_OUTPUT);
catalogOutput.setDescription("Output Folder (catalog)");
catalogOutput.setOutputDirectory("./"+CUBE_CATALOG_DIRECTORY);
catalogOutput.setOverrideExistingResources(true);
catalogOutput.setCreateOutputDirectory(true);
catalogOutput.setCleanUpDerivedResources(true);
catalogOutput.setSetDerivedProperty(true);
configs.add(catalogOutput);
// LOGGER.debug("cube:{}", catalogOutput);
OutputConfiguration resourceOutput = new OutputConfiguration(DEFAULT_OUTPUT_I18N);
resourceOutput.setDescription("Output Folder (i18n)");
if(!NAMEDDEFAULTDIRECTORY || extensions == null) {
resourceOutput.setOutputDirectory("./"+I18N_OUTPUT_DIRECTORY);
} else {
resourceOutput.setOutputDirectory("./"+I18N_OUTPUT_DIRECTORY+"_"+extensions);
}
resourceOutput.setOverrideExistingResources(true);
resourceOutput.setCreateOutputDirectory(true);
resourceOutput.setCleanUpDerivedResources(false);
resourceOutput.setSetDerivedProperty(false);
configs.add(resourceOutput);
// LOGGER.debug("i18n:{}", resourceOutput);
OutputConfiguration reportOutput = new OutputConfiguration(DEFAULT_REPORT_OUTPUT);
reportOutput.setDescription("Output Folder");
reportOutput.setOutputDirectory("./rptdesign-gen");
reportOutput.setOverrideExistingResources(true);
reportOutput.setCreateOutputDirectory(true);
reportOutput.setCleanUpDerivedResources(true);
reportOutput.setSetDerivedProperty(true);
configs.add(reportOutput);
// LOGGER.debug("report:{}", reportOutput);
OutputConfiguration dtoOutput = new OutputConfiguration("DTOs");
dtoOutput.setDescription("derived DTOs");
dtoOutput.setOutputDirectory("./dto-models");
dtoOutput.setOverrideExistingResources(false);
dtoOutput.setCreateOutputDirectory(true);
dtoOutput.setCleanUpDerivedResources(false);
dtoOutput.setSetDerivedProperty(false);
dtoOutput.setKeepLocalHistory(true);
configs.add(dtoOutput);
// LOGGER.debug("dto:{}", dtoOutput);
OutputConfiguration dtoMapperOutput = new OutputConfiguration(
"Dto-Mappers");
dtoMapperOutput.setDescription("Dto Mappers");
if(!NAMEDDEFAULTDIRECTORY) {
dtoMapperOutput.setOutputDirectory("./src-gen");
} else {
dtoMapperOutput.setOutputDirectory("./src-mappers");
}
dtoMapperOutput.setOverrideExistingResources(true);
dtoMapperOutput.setCreateOutputDirectory(true);
dtoMapperOutput.setCleanUpDerivedResources(true);
dtoMapperOutput.setSetDerivedProperty(true);
dtoMapperOutput.setKeepLocalHistory(true);
configs.add(dtoMapperOutput);
// LOGGER.debug("dtoMapper:{}", dtoMapperOutput);
OutputConfiguration servicesOutput = new OutputConfiguration(
"Services-DSL");
servicesOutput.setDescription("Services-DSL");
servicesOutput.setOutputDirectory("./service-models");
servicesOutput.setOverrideExistingResources(true);
servicesOutput.setCreateOutputDirectory(true);
servicesOutput.setCleanUpDerivedResources(true);
servicesOutput.setSetDerivedProperty(true);
servicesOutput.setKeepLocalHistory(true);
configs.add(servicesOutput);
// LOGGER.debug("service:{}", servicesOutput);
OutputConfiguration binOutput = new OutputConfiguration(
"ModelBin");
binOutput.setDescription("ModelBin");
binOutput.setOutputDirectory("./modelsbin");
binOutput.setOverrideExistingResources(true);
binOutput.setCreateOutputDirectory(true);
binOutput.setCleanUpDerivedResources(true);
binOutput.setSetDerivedProperty(true);
binOutput.setKeepLocalHistory(true);
configs.add(binOutput);
// LOGGER.debug("modelbin:{}", binOutput);
OutputConfiguration configOutput = new OutputConfiguration(CONFIGURATION_DIRECTORY);
configOutput.setDescription("Configuration Folder (once)");
configOutput.setOutputDirectory("./"+CONFIGURATION_DIRECTORY);
configOutput.setOverrideExistingResources(false);
configOutput.setCreateOutputDirectory(true);
configOutput.setCleanUpDerivedResources(false);
configOutput.setSetDerivedProperty(false);
configs.add(configOutput);
// LOGGER.debug("configuration:{}", configOutput);
OutputConfiguration xmiOutput = new OutputConfiguration("xmi");
xmiOutput.setDescription("xmi");
xmiOutput.setOutputDirectory("./modelsbin");
xmiOutput.setOverrideExistingResources(true);
xmiOutput.setCreateOutputDirectory(true);
xmiOutput.setCleanUpDerivedResources(true);
xmiOutput.setSetDerivedProperty(true);
xmiOutput.setKeepLocalHistory(true);
configs.add(xmiOutput);
// LOGGER.debug("xmi:{}", xmiOutput);
OutputConfiguration ecviewOutput = new OutputConfiguration("Autowire-ECViews");
ecviewOutput.setDescription("Autowired ECViews");
ecviewOutput.setOutputDirectory("./ecviews");
ecviewOutput.setOverrideExistingResources(true);
ecviewOutput.setCreateOutputDirectory(true);
ecviewOutput.setCleanUpDerivedResources(true);
ecviewOutput.setSetDerivedProperty(true);
ecviewOutput.setKeepLocalHistory(true);
configs.add(ecviewOutput);
// LOGGER.debug("ecviews:{}", ecviewOutput);
OutputConfiguration componentOutput = new OutputConfiguration("OSGI-INF");
componentOutput.setDescription("OSGi-Services");
componentOutput.setOutputDirectory("./OSGI-INF");
componentOutput.setOverrideExistingResources(true);
componentOutput.setCreateOutputDirectory(true);
componentOutput.setCleanUpDerivedResources(true);
componentOutput.setSetDerivedProperty(true);
componentOutput.setKeepLocalHistory(true);
configs.add(componentOutput);
// LOGGER.debug("osgi:{}", componentOutput);
return configs;
}
}