Search in sources :

Example 1 with CreateMavenJobPom

use of org.talend.designer.maven.tools.creator.CreateMavenJobPom in project tdi-studio-se by Talend.

the class MavenJavaProcessor method createMavenPomCreator.

protected IMavenPomCreator createMavenPomCreator() {
    final Property itemProperty = this.getProperty();
    String buildTypeName = null;
    // FIXME, better use the arguments directly for run/export/build/..., and remove this flag later.
    if (ProcessorUtilities.isExportConfig()) {
        // final Object exportType = itemProperty.getAdditionalProperties().get(MavenConstants.NAME_EXPORT_TYPE);
        final Object exportType = getArguments().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
        buildTypeName = exportType != null ? exportType.toString() : null;
    }
    // else { //if run job, will be null (use Standalone by default)
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(IBuildParametes.ITEM, itemProperty.getItem());
    parameters.put(IBuildPomCreatorParameters.PROCESSOR, this);
    parameters.put(IBuildPomCreatorParameters.FILE_POM, getPomFile());
    parameters.put(IBuildPomCreatorParameters.FILE_ASSEMBLY, getAssemblyFile());
    parameters.put(IBuildPomCreatorParameters.CP_LINUX, this.unixClasspath);
    parameters.put(IBuildPomCreatorParameters.CP_WIN, this.windowsClasspath);
    parameters.put(IBuildPomCreatorParameters.ARGUMENTS_MAP, getArguments());
    parameters.put(IBuildPomCreatorParameters.OVERWRITE_POM, Boolean.TRUE);
    AbstractBuildProvider foundBuildProvider = BuildExportManager.getInstance().getBuildProvider(buildTypeName, parameters);
    if (foundBuildProvider != null) {
        final IMavenPomCreator creator = foundBuildProvider.createPomCreator(parameters);
        if (creator != null) {
            return creator;
        }
    }
    // normally, won't be here, should return creator in font.
    CreateMavenJobPom createTemplatePom = new CreateMavenJobPom(this, getPomFile());
    createTemplatePom.setUnixClasspath(this.unixClasspath);
    createTemplatePom.setWindowsClasspath(this.windowsClasspath);
    createTemplatePom.setAssemblyFile(getAssemblyFile());
    IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(this.getProperty());
    IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(this.getProperty());
    if (itemLocationPath != null && objectTypeFolder != null) {
        IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
        createTemplatePom.setObjectTypeFolder(objectTypeFolder);
        createTemplatePom.setItemRelativePath(itemRelativePath);
    }
    return createTemplatePom;
}
Also used : AbstractBuildProvider(org.talend.core.runtime.repository.build.AbstractBuildProvider) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) CreateMavenJobPom(org.talend.designer.maven.tools.creator.CreateMavenJobPom) IMavenPomCreator(org.talend.core.runtime.repository.build.IMavenPomCreator) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with CreateMavenJobPom

use of org.talend.designer.maven.tools.creator.CreateMavenJobPom in project tdi-studio-se by Talend.

the class StandardJobStandaloneBuildProvider method createPomCreator.

@Override
public IMavenPomCreator createPomCreator(Map<String, Object> parameters) {
    if (parameters == null || parameters.isEmpty()) {
        return null;
    }
    final Object processor = parameters.get(PROCESSOR);
    if (processor == null || !(processor instanceof IProcessor)) {
        return null;
    }
    final Object pomFile = parameters.get(FILE_POM);
    if (pomFile == null || !(pomFile instanceof IFile)) {
        return null;
    }
    final Object item = parameters.get(ITEM);
    if (item == null || !(item instanceof Item)) {
        return null;
    }
    Object argumentsMap = parameters.get(ARGUMENTS_MAP);
    if (argumentsMap == null) {
        argumentsMap = Collections.emptyMap();
    }
    if (!(argumentsMap instanceof Map)) {
        return null;
    }
    Object overwrite = parameters.get(OVERWRITE_POM);
    if (overwrite == null) {
        overwrite = Boolean.FALSE;
    }
    final Object assemblyFile = parameters.get(FILE_ASSEMBLY);
    if (assemblyFile == null || !(assemblyFile instanceof IFile)) {
        return null;
    }
    final Object winClassPath = parameters.get(CP_WIN);
    if (winClassPath == null) {
        return null;
    }
    final Object linuxClassPath = parameters.get(CP_LINUX);
    if (linuxClassPath == null) {
        return null;
    }
    CreateMavenJobPom creator = new CreateMavenJobPom((IProcessor) processor, (IFile) pomFile);
    creator.setUnixClasspath(linuxClassPath.toString());
    creator.setWindowsClasspath(winClassPath.toString());
    creator.setAssemblyFile((IFile) assemblyFile);
    creator.setArgumentsMap((Map<String, Object>) argumentsMap);
    creator.setOverwrite(Boolean.parseBoolean(overwrite.toString()));
    final Property itemProperty = ((Item) item).getProperty();
    IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(itemProperty);
    IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(itemProperty);
    if (itemLocationPath != null && objectTypeFolder != null) {
        IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
        creator.setObjectTypeFolder(objectTypeFolder);
        creator.setItemRelativePath(itemRelativePath);
    }
    return creator;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CreateMavenJobPom(org.talend.designer.maven.tools.creator.CreateMavenJobPom) IProcessor(org.talend.designer.runprocess.IProcessor) Map(java.util.Map) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with CreateMavenJobPom

use of org.talend.designer.maven.tools.creator.CreateMavenJobPom in project tdi-studio-se by Talend.

the class BigDataJavaProcessor method createMavenPomCreator.

@Override
protected IMavenPomCreator createMavenPomCreator() {
    IMavenPomCreator createMavenTemplatePom = super.createMavenPomCreator();
    if (createMavenTemplatePom instanceof CreateMavenJobPom) {
        CreateMavenJobPom createMavenJobPom = (CreateMavenJobPom) createMavenTemplatePom;
        if (!StringUtils.isBlank(this.windowsAddition)) {
            String windowsScriptAddition = createMavenJobPom.getWindowsScriptAddition();
            if (windowsScriptAddition != null && windowsScriptAddition.length() > 0) {
                // add one space to separate existed additions.
                windowsScriptAddition += ' ';
            } else {
                //$NON-NLS-1$
                windowsScriptAddition = "";
            }
            windowsScriptAddition += ProcessorConstants.CMD_KEY_WORD_LIBJAR + ' ' + this.windowsAddition;
            createMavenJobPom.setWindowsScriptAddition(windowsScriptAddition);
        }
        if (!StringUtils.isBlank(this.unixAddition)) {
            String unixScriptAddition = createMavenJobPom.getUnixScriptAddition();
            if (unixScriptAddition != null && unixScriptAddition.length() > 0) {
                // add one space to separate existed additions.
                unixScriptAddition += ' ';
            } else {
                //$NON-NLS-1$
                unixScriptAddition = "";
            }
            unixScriptAddition += ProcessorConstants.CMD_KEY_WORD_LIBJAR + ' ' + this.unixAddition;
            createMavenJobPom.setUnixCcriptAddition(unixScriptAddition);
        }
    }
    return createMavenTemplatePom;
}
Also used : CreateMavenJobPom(org.talend.designer.maven.tools.creator.CreateMavenJobPom) IMavenPomCreator(org.talend.core.runtime.repository.build.IMavenPomCreator)

Aggregations

CreateMavenJobPom (org.talend.designer.maven.tools.creator.CreateMavenJobPom)3 IFolder (org.eclipse.core.resources.IFolder)2 IPath (org.eclipse.core.runtime.IPath)2 Property (org.talend.core.model.properties.Property)2 IMavenPomCreator (org.talend.core.runtime.repository.build.IMavenPomCreator)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IFile (org.eclipse.core.resources.IFile)1 Item (org.talend.core.model.properties.Item)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 AbstractBuildProvider (org.talend.core.runtime.repository.build.AbstractBuildProvider)1 IProcessor (org.talend.designer.runprocess.IProcessor)1