Compare commits

...

9 Commits

5 changed files with 53 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.core.model.components;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -138,6 +139,17 @@ public interface IComponent {
*/
public List<ModuleNeeded> getModulesNeeded(INode node);
/**
* Return additional artifacts required in Job's runtime according the setup of a component.
* Default implementation returns empty list
*
* @param node Component node
* @return list of additional artifacts needed in runtime
*/
public default List<ModuleNeeded> getRuntimeArtifacts(INode node) {
return Collections.emptyList();
}
public String getPathSource();
public List<ECodePart> getAvailableCodeParts();

View File

@@ -32,6 +32,8 @@ public class LastGenerationInfo {
private HashMap<String, Set<String>> pigudfNeededPerJob;
private HashMap<String, Set<ModuleNeeded>> modulesNeededWithSubjobPerJob;
private HashMap<String, Set<ModuleNeeded>> additionalLibraries;
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeeded;
@@ -55,6 +57,7 @@ public class LastGenerationInfo {
modulesNeededPerJob = new HashMap<String, Set<ModuleNeeded>>();
contextPerJob = new HashMap<String, Set<String>>();
modulesNeededWithSubjobPerJob = new HashMap<String, Set<ModuleNeeded>>();
additionalLibraries = new HashMap<>();
highPriorityModuleNeeded = new HashMap<>();
lastGeneratedjobs = new HashSet<JobInfo>();
routinesNeededPerJob = new HashMap<String, Set<String>>();
@@ -97,6 +100,14 @@ public class LastGenerationInfo {
return modulesNeededPerJob.get(key);
}
public Set<ModuleNeeded> getAdditionalLibraries(final String jobId, final String jobVersion) {
final String key = computeJobKey(jobId, jobVersion);
if (!additionalLibraries.containsKey(key)) {
additionalLibraries.put(key, new HashSet<>());
}
return additionalLibraries.get(key);
}
/**
* Getter for contextPerJob.
*
@@ -120,6 +131,14 @@ public class LastGenerationInfo {
modulesNeededPerJob.put(key, new HashSet<ModuleNeeded>(modulesNeeded));
}
public void setAdditionalLibraries(final String jobId, final String jobVersion, final Set<ModuleNeeded> additionalArtifacts) {
additionalLibraries.put(computeJobKey(jobId, jobVersion), new HashSet<>(additionalArtifacts));
}
private String computeJobKey(final String jobId, final String jobVersion) {
return jobId + "_" + jobVersion;
}
/**
* Sets the modulesNeededWithSubjobPerJob.
*
@@ -370,6 +389,7 @@ public class LastGenerationInfo {
public void clean() {
modulesNeededPerJob.clear();
additionalLibraries.clear();
routinesNeededPerJob.clear();
pigudfNeededPerJob.clear();
modulesNeededWithSubjobPerJob.clear();

View File

@@ -14,6 +14,7 @@ package org.talend.designer.core;
import java.beans.PropertyChangeEvent;
import java.io.Reader;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -161,6 +162,10 @@ public interface IDesignerCoreService extends IService {
public Set<ModuleNeeded> getNeededModules(INode node, boolean withChildrens);
public default Set<ModuleNeeded> getAdditionalLibrariesForProcess(IProcess process) {
return Collections.emptySet();
}
public void switchToCurContextsView();
public void switchToCurComponentSettingsView();

View File

@@ -1109,6 +1109,12 @@ public class ProcessorUtilities {
}
}
// setup additional libraries needed in runtime
final Set<ModuleNeeded> additionalLibraries = CorePlugin.getDefault().getDesignerCoreService()
.getAdditionalLibrariesForProcess(currentProcess);
LastGenerationInfo.getInstance().setAdditionalLibraries(jobInfo.getJobId(),
jobInfo.getJobVersion(), additionalLibraries);
Map<String, Object> argumentsMap = jobInfo.getArgumentsMap();
if (argumentsMap != null) {
processor.setArguments(argumentsMap);

View File

@@ -684,6 +684,16 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
Dependency dependency = PomUtil.createModuleDependency(mavenUri);
dependencies.add(dependency);
}
final IProcess currentProcess = getJobProcessor().getProcess();
final Set<ModuleNeeded> additionalArtifacts = LastGenerationInfo.getInstance()
.getAdditionalLibraries(currentProcess.getId(), currentProcess.getVersion());
for (final ModuleNeeded module : additionalArtifacts) {
final String mavenUri = module.getMavenUri();
final Dependency dependency = PomUtil.createModuleDependency(mavenUri);
dependencies.add(dependency);
}
for (Dependency dependency : dependencies) {
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
continue;