Compare commits

...

13 Commits

Author SHA1 Message Date
kjwang-talend
46804c5b7b Kjwang/fix tup 21401 high cve vulnerability found in talend components (#2164) (#2191)
* Fix TUP-21401 High CVE Vulnerability found in Talend Components
https://jira.talendforge.org/browse/TUP-21401

* Fix TUP-21401 High CVE Vulnerability found in Talend Components
https://jira.talendforge.org/browse/TUP-21401
2019-03-04 14:30:27 +08:00
kjwang-talend
87e73138e6 Fix TUP-21911 Build job takes about 4 minutes while Run job takes > 40 (#2242) (#2244)
minutes to start
https://jira.talendforge.org/browse/TUP-21911
2019-02-25 19:14:34 +08:00
Olivier Tassetti
77808f4c55 Pin maven-surefire-plugin version (#2243) 2019-02-14 16:44:40 +01:00
hcyi
cec605bf4d fix(TUP-20974): [BUG] Impala connection failed on CDH 6.0.0 (#1979) (#2199)
https://jira.talendforge.org/browse/TUP-20974

Fix url problem
2019-02-11 11:43:06 +08:00
Vladimir Bogatyrov
5fdf7e91fe [TESB-24543] The schema include is incorrect: namespaces are not equals 2019-02-05 09:51:49 +02:00
Laurent BOURGEOIS
49e52d4af2 "talend-bigdata-launcher-1.2.0-20170410.jar" not found when spark job launched from standard job by jobserver 2019-02-04 00:12:28 +01:00
zwxue
154c38983c fix(TUP-21532):fix NPE. 2019-01-23 19:15:58 +08:00
Zhiwei Xue
138a5d620a fix(TUP-21532):re-fix child assembly problem. (#2213) 2019-01-22 14:17:32 +08:00
Zhiwei Xue
1c257b873f fix(TUP-21532):remove assembly file filtered setting. (#2170) 2019-01-22 14:14:49 +08:00
Zhiwei Xue
8a67969b9c fix(TUP-21532):Standard DI job which refers to big data batch job having
S3 component and standard DI job having S3 connection component fails
with an error.
2019-01-22 13:13:18 +08:00
zwxue
0832273bef fix(TUP-21127):fix routine dependency problem after doing merge (#2028) (#2039) 2019-01-08 11:13:26 +08:00
jiezhang-tlnd
58505f25f4 Jzhang/bugfix backport711/tup 21005 in studio java debugging of routes fails (#1966)
* fix(TUP-21005)In studio Java Debugging of Routes fails

* fix(TUP-21005)overload the changepath method
2019-01-07 14:49:29 +08:00
Mike Yan
4285c3124a fix(TESB-24018):SOAP DS-Operation bundle job of service are not deployed (#1967) 2018-11-01 15:22:11 +08:00
23 changed files with 466 additions and 128 deletions

View File

@@ -432,6 +432,9 @@ public interface IRepositoryFactory {
public List<ILockBean> getAllRemoteLocks();
public void loadProjectAndSetContext(IProject eclipseProject) throws PersistenceException;
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
throws PersistenceException;
public byte[] getReferenceSettingContent(Project project, String branch) throws PersistenceException;

View File

@@ -1587,6 +1587,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
this.repositoryFactoryFromProvider.loadProjectAndSetContext(eclipseProject);
}
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
throws PersistenceException {
this.repositoryFactoryFromProvider.loadProjectAndSetContext(project, eclipseProject, updateCurrentProject);
}
/**
* DOC smallet Comment method "emptyTempFolder".
*

View File

@@ -46,6 +46,8 @@ public class ModuleNeeded {
private boolean required;
private boolean excluded;
private boolean mrRequired = false; // That indicates if the module is
// required by M/R job.
@@ -293,6 +295,14 @@ public class ModuleNeeded {
this.required = required;
}
public boolean isExcluded() {
return this.excluded;
}
public void setExcluded(boolean excluded) {
this.excluded = excluded;
}
public ELibraryInstallStatus getStatus() {
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);

View File

@@ -128,8 +128,6 @@ public class RelationshipItemBuilder {
private Map<Relation, Set<Relation>> referencesItemsRelations;
private Map<String, String> hadoopItemReferences = new HashMap<String, String>();
private boolean loaded = false;
private boolean loading = false;
@@ -1097,10 +1095,11 @@ public class RelationshipItemBuilder {
Map<Relation, Set<Relation>> relations = handler.find(item);
mergeRelationship(itemRelations, relations);
}
if (oldProjectRelations != null) {
// check if there is any changes on the relations.
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
// check if there is any changes on the relations.
Set<Relation> newProjectRelations = currentProjectItemsRelations.get(relation);
if (oldProjectRelations == null && newProjectRelations == null) {
relationsModified = false;
} else if (oldProjectRelations != null) {
if (oldProjectRelations.size() == newProjectRelations.size()) {
relationsModified = false;
for (Relation newRelation : newProjectRelations) {

View File

@@ -1498,4 +1498,20 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
}
return allTypes;
}
public static List<ERepositoryObjectType> getAllTypesOfCodes() {
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
if (ERepositoryObjectType.ROUTINES != null) {
allTypes.add(ERepositoryObjectType.ROUTINES);
}
ERepositoryObjectType beansType = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
if (beansType != null) {
allTypes.add(beansType);
}
if (ERepositoryObjectType.PIG_UDF != null) {
allTypes.add(ERepositoryObjectType.PIG_UDF);
}
return allTypes;
}
}

View File

@@ -69,4 +69,6 @@ public interface TalendProcessOptionConstants {
public static final int MODULES_FOR_MR = 1 << 4;
public static final int MODULES_EXCLUDE_SHADED = 1 << 5;
}

View File

@@ -222,6 +222,8 @@ public interface IRunProcessService extends IService {
boolean isExportConfig();
boolean isdebug();
void generatePom(Item item);
void generatePom(Item item, int option);

View File

@@ -165,6 +165,8 @@ public class ProcessorUtilities {
private static final Set<String> esbJobs = new HashSet<String>();
private static boolean isDebug = false;
public static void addOpenEditor(IEditorPart editor) {
openedEditors.add(editor);
}
@@ -505,7 +507,7 @@ public class ProcessorUtilities {
mainRelation.setId(jobInfo.getJobId());
mainRelation.setVersion(jobInfo.getJobVersion());
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
hasLoopDependency = checkLoopDependencies(mainRelation);
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
// clean the previous code in case it has deleted subjob
cleanSourceFolder(progressMonitor, currentProcess, processor);
}
@@ -605,28 +607,29 @@ public class ProcessorUtilities {
return processor;
}
private static boolean checkLoopDependencies(Relation mainJobInfo) throws ProcessorException {
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo);
private static boolean checkLoopDependencies(Relation mainJobInfo, Map<String, String> idToLastestVersionMap)
throws ProcessorException {
List<Relation> itemsJobRelatedTo = getItemsRelation(mainJobInfo, idToLastestVersionMap);
List<Relation> relationChecked = new ArrayList<>();
relationChecked.add(mainJobInfo);
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked);
return checkLoopDependencies(mainJobInfo, itemsJobRelatedTo, relationChecked, idToLastestVersionMap);
}
private static boolean checkLoopDependencies(Relation mainRelation, List<Relation> itemsJobRelatedTo,
List<Relation> relationChecked) throws ProcessorException {
List<Relation> relationChecked, Map<String, String> idToLastestVersionMap) throws ProcessorException {
boolean hasDependency = false;
for (Relation relation : itemsJobRelatedTo) {
hasDependency = relation.getId().equals(mainRelation.getId())
&& relation.getVersion().equals(mainRelation.getVersion());
if (!hasDependency) {
List<Relation> itemsChildJob = getItemsRelation(relation);
List<Relation> itemsChildJob = getItemsRelation(relation, idToLastestVersionMap);
if (!relationChecked.contains(relation)) {
relationChecked.add(relation);
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked);
hasDependency = checkLoopDependencies(mainRelation, itemsChildJob, relationChecked, idToLastestVersionMap);
}
if (!hasDependency) {
for (Relation childRelation : itemsChildJob) {
hasDependency = checkLoopDependencies(childRelation);
hasDependency = checkLoopDependencies(childRelation, idToLastestVersionMap);
if (hasDependency) {
break;
}
@@ -641,7 +644,7 @@ public class ProcessorUtilities {
return hasDependency;
}
private static List<Relation> getItemsRelation(Relation mainJobInfo) throws ProcessorException {
private static List<Relation> getItemsRelation(Relation mainJobInfo, Map<String, String> idToLastestVersionMap) throws ProcessorException {
List<Relation> itemsJobRelatedTo = new ArrayList<Relation>();
try {
List<Project> allProjects = new ArrayList<Project>();
@@ -655,12 +658,17 @@ public class ProcessorUtilities {
mainJobInfo.getType(), RelationshipItemBuilder.JOBLET_RELATION));
for (Relation relation : itemsJobRelatedTo) {
if (relation.getVersion().equals(RelationshipItemBuilder.LATEST_VERSION)) {
for (Project project : allProjects) {
IRepositoryViewObject lastVersion =
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
if (lastVersion != null) {
relation.setVersion(lastVersion.getVersion());
break;
if (idToLastestVersionMap.containsKey(relation.getId())) {
relation.setVersion(idToLastestVersionMap.get(relation.getId()));
} else {
for (Project project : allProjects) {
IRepositoryViewObject lastVersion =
ProxyRepositoryFactory.getInstance().getLastVersion(project, relation.getId());
if (lastVersion != null) {
relation.setVersion(lastVersion.getVersion());
idToLastestVersionMap.put(relation.getId(), relation.getVersion());
break;
}
}
}
}
@@ -1015,7 +1023,7 @@ public class ProcessorUtilities {
mainRelation.setId(jobInfo.getJobId());
mainRelation.setVersion(jobInfo.getJobVersion());
mainRelation.setType(RelationshipItemBuilder.JOB_RELATION);
hasLoopDependency = checkLoopDependencies(mainRelation);
hasLoopDependency = checkLoopDependencies(mainRelation, new HashMap<String, String>());
// clean the previous code in case it has deleted subjob
cleanSourceFolder(progressMonitor, currentProcess, processor);
}
@@ -2494,4 +2502,12 @@ public class ProcessorUtilities {
return false;
}
public static void setDebug(boolean debug) {
isDebug = debug;
}
public static boolean isdebug() {
return isDebug;
}
}

View File

@@ -63,6 +63,28 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>3.5.37</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>

View File

@@ -48,4 +48,6 @@ public class MavenSystemFolders {
public static final ProjectSystemFolder[] TEST_DIRS = { JAVA_TEST, RESOURCES_TEST };
public static final ProjectSystemFolder[] ALL_DIRS = { JAVA, JAVA_TEST, RESOURCES, RESOURCES_TEST };
public static final ProjectSystemFolder[] ALL_DIRS_EXT = { JAVA, JAVA_TEST, RESOURCES, RESOURCES_TEST, EXT_RESOURCES };
}

View File

@@ -263,6 +263,12 @@ public class BuildCacheManager {
codesLastBuildCache.remove(codeType);
}
public void clearAllCodesCache() {
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
codesLastBuildCache.remove(codeType);
}
}
public void clearAllCaches() {
jobCache.clear();
jobletCache.clear();

View File

@@ -22,6 +22,8 @@ import java.util.Set;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IFile;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ILibraryManagerService;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
import org.talend.core.model.properties.Property;
@@ -102,8 +104,19 @@ public abstract class AbstractMavenCodesTemplatePom extends AbstractMavenGeneral
for (ModuleNeeded module : needModules) {
Dependency dependency = null;
// TDI-37032 add dependency only if jar avialable in maven
if (module.getDeployStatus() == ELibraryInstallStatus.DEPLOYED) {
// TDI-37032 add dependency only if jar available in maven
boolean isDeployed = false;
if (module.getDeployStatus() != ELibraryInstallStatus.DEPLOYED) {
// try to retrieve from custom Nexus
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService libManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);
isDeployed = libManagerService.retrieve(module, null, false);
}
} else {
isDeployed = true;
}
if (isDeployed) {
dependency = PomUtil.createModuleDependency(module.getMavenUri());
}
if (dependency != null) {

View File

@@ -208,11 +208,12 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
Xpp3Dom artifactSet = new Xpp3Dom("artifactSet"); //$NON-NLS-1$
configuration.addChild(artifactSet);
Xpp3Dom excludes = new Xpp3Dom("excludes"); //$NON-NLS-1$
if (!bigDataProcessor.getShadedModulesExclude().isEmpty()) {
Set<ModuleNeeded> modules = bigDataProcessor.getShadedModulesExclude();
if (!modules.isEmpty()) {
artifactSet.addChild(excludes);
}
for (ModuleNeeded module : bigDataProcessor.getShadedModulesExclude()) {
for (ModuleNeeded module : modules) {
Xpp3Dom include = new Xpp3Dom("exclude"); //$NON-NLS-1$
excludes.addChild(include);
MavenArtifact mvnArtifact = MavenUrlHelper.parseMvnUrl(module.getMavenUri());

View File

@@ -16,24 +16,32 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.VersionUtils;
@@ -74,6 +82,8 @@ import org.talend.designer.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.RepositoryConstants;
import org.talend.utils.io.FilesUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
* created by ggu on 4 Feb 2015 Detailled comment
@@ -599,54 +609,45 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
MavenTemplateManager.saveContent(infoFile, jobInfoContent, overwrite);
}
public void updateDependencySet(IFile assemblyFile) {
final String SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
String talendlibIncludesTag = "<!--@TalendLibIncludes@-->"; //$NON-NLS-1$
String _3rdlibExcludesTag = "<!--@3rdPartyLibIncludes@-->"; //$NON-NLS-1$
String jobIncludesTag = "<!--@JobIncludes@-->"; //$NON-NLS-1$
StringBuilder talendlibIncludes = new StringBuilder();
StringBuilder _3rdPartylibExcludes = new StringBuilder();
StringBuilder jobIncludes = new StringBuilder();
Set<String> childrenCoordinate = new HashSet<>();
protected void updateDependencySet(IFile assemblyFile) {
Set<String> jobCoordinate = new HashSet<>();
Set<JobInfo> childrenJobInfo = new HashSet<>();
if (!hasLoopDependency()) {
// add children jobs
Set<JobInfo> childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String groupId = PomIdsHelper.getJobGroupId(property);
String artifactId = PomIdsHelper.getJobArtifactId(jobInfo);
String coordinate = groupId + ":" + artifactId; //$NON-NLS-1$
addItem(jobIncludes, coordinate, SEPARATOR);
childrenCoordinate.add(coordinate);
}
childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
}
// add children jobs
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
jobCoordinate.add(coordinate);
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate = PomIdsHelper.getJobGroupId(parentProperty) + ":" //$NON-NLS-1$
+ PomIdsHelper.getJobArtifactId(parentProperty);
addItem(jobIncludes, parentCoordinate, SEPARATOR);
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
PomIdsHelper.getJobVersion(parentProperty));
jobCoordinate.add(parentCoordinate);
// add talend libraries and codes
Set<String> talendLibCoordinate = new HashSet<>();
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
// codes
List<Dependency> dependencies = new ArrayList<>();
addCodesDependencies(dependencies);
for (Dependency dependency : dependencies) {
String dependencyGroupId = dependency.getGroupId();
String coordinate = dependencyGroupId + ":" + dependency.getArtifactId(); //$NON-NLS-1$
addItem(talendlibIncludes, coordinate, SEPARATOR);
talendLibCoordinate.add(coordinate);
talendLibCoordinate.add(getCoordinate(dependency));
}
// libraries
dependencies.clear();
Set<ModuleNeeded> modules =
getJobProcessor().getNeededModules(TalendProcessOptionConstants.MODULES_WITH_JOBLET);
getJobProcessor().getNeededModules(
TalendProcessOptionConstants.MODULES_WITH_JOBLET | TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED);
for (ModuleNeeded module : modules) {
String mavenUri = module.getMavenUri();
Dependency dependency = PomUtil.createModuleDependency(mavenUri);
@@ -657,10 +658,9 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
continue;
}
String dependencyGroupId = dependency.getGroupId();
String coordinate = dependencyGroupId + ":" + dependency.getArtifactId(); //$NON-NLS-1$
if (!childrenCoordinate.contains(coordinate)) {
String coordinate = getCoordinate(dependency);
if (!jobCoordinate.contains(coordinate)) {
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)) {
addItem(talendlibIncludes, coordinate, SEPARATOR);
talendLibCoordinate.add(coordinate);
}
}
@@ -668,62 +668,176 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
// add 3rd party libraries
Set<String> _3rdDepLib = new HashSet<>();
Map<String, Set<Dependency>> duplicateLibs = new HashMap<>();
for (Dependency dependency : dependencies) {
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
continue;
}
String coordinate = dependency.getGroupId() + ":" + dependency.getArtifactId(); //$NON-NLS-1$
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
String coordinate = getCoordinate(dependency);
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)) {
_3rdDepLib.add(coordinate);
addItem(_3rdPartylibExcludes, coordinate, SEPARATOR);
addToDuplicateLibs(duplicateLibs, dependency);
}
}
// add missing modules from the job generation of children
Set<JobInfo> allJobs = LastGenerationInfo.getInstance().getLastGeneratedjobs();
Set<ModuleNeeded> fullModulesList = new HashSet<>();
for (JobInfo jobInfo : allJobs) {
for (JobInfo jobInfo : childrenJobInfo) {
fullModulesList.addAll(LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(jobInfo.getJobId(),
jobInfo.getJobVersion()));
}
for (ModuleNeeded moduleNeeded : fullModulesList) {
if (moduleNeeded.isExcluded()) {
continue;
}
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
String coordinate = artifact.getGroupId() + ":" + artifact.getArtifactId(); //$NON-NLS-1$
if (!childrenCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
String coordinate = getCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(),
artifact.getVersion());
if (!jobCoordinate.contains(coordinate) && !talendLibCoordinate.contains(coordinate)
&& !_3rdDepLib.contains(coordinate)) {
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|| artifact.getGroupId().startsWith(projectGroupId)) {
addItem(talendlibIncludes, coordinate, SEPARATOR);
talendLibCoordinate.add(coordinate);
} else {
addItem(_3rdPartylibExcludes, coordinate, SEPARATOR);
_3rdDepLib.add(coordinate);
Dependency dependency = PomUtil.createDependency(artifact.getGroupId(), artifact.getArtifactId(),
artifact.getVersion(), artifact.getType(), artifact.getClassifier());
addToDuplicateLibs(duplicateLibs, dependency);
}
}
}
if (_3rdPartylibExcludes.length() == 0) {
// if removed, it might add many unwanted dependencies to the libs folder. (or we should simply remove
// the full empty block of dependencySet)
addItem(_3rdPartylibExcludes, "null:null", SEPARATOR); //$NON-NLS-1$
Iterator<String> iterator = duplicateLibs.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Set<Dependency> dupDependencies = duplicateLibs.get(key);
if (dupDependencies.size() < 2) {
// remove non-duplicated dependencies
iterator.remove();
} else {
// remove duplicated dependencies from 3rd lib list
for (Dependency dependency : dupDependencies) {
_3rdDepLib.remove(getCoordinate(dependency));
}
}
}
String talendLibIncludesStr = StringUtils.removeEnd(talendlibIncludes.toString(), SEPARATOR);
String _3rdPartylibExcludesStr = StringUtils.removeEnd(_3rdPartylibExcludes.toString(), SEPARATOR);
String jobIncludesStr = StringUtils.removeEnd(jobIncludes.toString(), SEPARATOR);
String content = org.talend.commons.utils.io.FilesUtils.readFileContent(assemblyFile);
content = StringUtils.replaceEach(content,
new String[] { talendlibIncludesTag, _3rdlibExcludesTag, jobIncludesTag },
new String[] { talendLibIncludesStr, _3rdPartylibExcludesStr, jobIncludesStr });
org.talend.commons.utils.io.FilesUtils.writeContentToFile(content, assemblyFile);
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add talend libs & codes
setupDependencySetNode(document, talendLibCoordinate, "lib", "${artifact.artifactId}.${artifact.extension}", false);
// add 3rd party libs <dependencySet>
setupDependencySetNode(document, _3rdDepLib, "lib", null, false);
// add jobs
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true);
// add duplicate dependencies if exists
setupFileNode(document, duplicateLibs);
PomUtil.saveAssemblyFile(assemblyFile, document);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
private void addItem(StringBuilder builder, String coordinate, String separator) {
if (builder.length() > 0) {
builder.append("\t\t\t\t"); //$NON-NLS-1$
private String getCoordinate(Dependency dependency) {
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), dependency.getVersion());
}
protected String getCoordinate(String groupId, String artifactId, String type, String version) {
String separator = ":"; //$NON-NLS-1$
String coordinate = groupId + separator;
coordinate += artifactId + separator;
if (type != null) {
coordinate += type;
}
if (version != null) {
coordinate += separator + version;
}
return coordinate;
}
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) {
String coordinate = getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null);
if (!map.containsKey(coordinate)) {
Set<Dependency> set = new HashSet<>();
map.put(coordinate, set);
}
map.get(coordinate).add(dependency);
}
protected void setupDependencySetNode(Document document, Set<String> libIncludes, String outputDir, String fileNameMapping,
boolean useProjectArtifact) {
if (libIncludes.isEmpty()) {
return;
}
Node dependencySetsNode = document.getElementsByTagName("dependencySets").item(0);
if (dependencySetsNode == null) {
return;
}
Node dependencySetNode = document.createElement("dependencySet");
dependencySetsNode.appendChild(dependencySetNode);
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent(outputDir);
dependencySetNode.appendChild(outputDirNode);
Node includesNode = document.createElement("includes");
dependencySetNode.appendChild(includesNode);
for (String include : libIncludes) {
Node includeNode = document.createElement("include");
includeNode.setTextContent(include);
includesNode.appendChild(includeNode);
}
if (StringUtils.isNotBlank(fileNameMapping)) {
Node fileNameMappingNode = document.createElement("outputFileNameMapping");
fileNameMappingNode.setTextContent(fileNameMapping);
dependencySetNode.appendChild(fileNameMappingNode);
}
Node useProjectArtifactNode = document.createElement("useProjectArtifact");
useProjectArtifactNode.setTextContent(Boolean.toString(useProjectArtifact));
dependencySetNode.appendChild(useProjectArtifactNode);
}
private void setupFileNode(Document document, Map<String, Set<Dependency>> duplicateDependencies) {
if (duplicateDependencies.isEmpty()) {
return;
}
try {
IMaven maven = MavenPlugin.getMaven();
ArtifactRepository repository = maven.getLocalRepository();
Node filesNode = document.getElementsByTagName("files").item(0);
for (Entry<String, Set<Dependency>> entry : duplicateDependencies.entrySet()) {
Set<Dependency> dependencies = entry.getValue();
for (Dependency dependency : dependencies) {
String sourceLocation = maven.getArtifactPath(repository, dependency.getGroupId(), dependency.getArtifactId(),
dependency.getVersion(), dependency.getType(), dependency.getClassifier());
Path path = new File(repository.getBasedir()).toPath().resolve(sourceLocation);
sourceLocation = path.toString();
String destName = path.getFileName().toString();
Node fileNode = document.createElement("file");
filesNode.appendChild(fileNode);
Node sourcesNode = document.createElement("source");
sourcesNode.setTextContent(sourceLocation);
fileNode.appendChild(sourcesNode);
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent("lib");
fileNode.appendChild(outputDirNode);
Node destNameNode = document.createElement("destName");
destNameNode.setTextContent(destName);
fileNode.appendChild(destNameNode);
}
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
builder.append("<include>"); //$NON-NLS-1$
builder.append(coordinate);
builder.append("</include>"); //$NON-NLS-1$
builder.append(separator);
}
}

View File

@@ -16,11 +16,14 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
@@ -35,6 +38,7 @@ import org.talend.core.model.process.JobInfo;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.process.TalendProcessOptionConstants;
@@ -43,9 +47,11 @@ import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IProcessor;
import org.talend.utils.io.FilesUtils;
import org.w3c.dom.Document;
/**
* @see OSGIJavaScriptForESBWithMavenManager to build job
@@ -144,20 +150,29 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
}
}
model.setName(model.getName() + " Bundle");
model.setPackaging("bundle");
model.addProperty("talend.job.finalName", "${talend.job.name}-bundle-${project.version}");
if (isServiceOperation) {
model.addProperty("cloud.publisher.skip", "true");
// Build build = model.getBuild();
// if(build != null) {
// List<Plugin> plugins = build.getPlugins();
// for(Plugin p : plugins) {
// if(p.getArtifactId().equals("maven-deploy-plugin")) {
// build.removePlugin(p);
// break;
// }
// }
// }
Build build = model.getBuild();
List<Plugin> removePlugins = new ArrayList<Plugin>();
if (build != null) {
List<Plugin> plugins = build.getPlugins();
for (Plugin p : plugins) {
if (p.getArtifactId().equals("maven-deploy-plugin")) {
removePlugins.add(p);
}
if (p.getArtifactId().equals("maven-bundle-plugin")) {
removePlugins.add(p);
}
}
}
for (Plugin p : removePlugins) {
build.removePlugin(p);
}
} else {
model.setPackaging("bundle");
}
return model;
@@ -196,6 +211,36 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
}
}
@Override
protected void updateDependencySet(IFile assemblyFile) {
Set<String> jobCoordinate = new HashSet<>();
if (!hasLoopDependency()) {
// add children jobs
Set<JobInfo> childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
jobCoordinate.add(coordinate);
}
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
PomIdsHelper.getJobVersion(parentProperty));
jobCoordinate.add(parentCoordinate);
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add jobs
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true);
PomUtil.saveAssemblyFile(assemblyFile, document);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
/*
* (non-Javadoc)
*

View File

@@ -22,7 +22,6 @@ import java.util.Set;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -43,9 +42,11 @@ import org.eclipse.m2e.core.project.ProjectImportConfiguration;
import org.osgi.service.prefs.BackingStoreException;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.generation.JavaUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.designer.maven.model.MavenSystemFolders;
import org.talend.designer.maven.model.ProjectSystemFolder;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.runprocess.IRunProcessService;
/**
* DOC zwxue class global comment. Detailled comment
@@ -93,8 +94,17 @@ public class MavenProjectUtils {
return;
}
MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getDefault()
.getService(IRunProcessService.class);
changeClasspath(monitor, project);
if (service.isdebug()) {
changeClasspath(monitor, project, MavenSystemFolders.ALL_DIRS_EXT);
} else {
changeClasspath(monitor, project);
}
}
// only need this when pom has no parent.
// IJavaProject javaProject = JavaCore.create(project);
@@ -102,6 +112,10 @@ public class MavenProjectUtils {
}
public static void changeClasspath(IProgressMonitor monitor, IProject p) {
changeClasspath(monitor, p, MavenSystemFolders.ALL_DIRS);
}
public static void changeClasspath(IProgressMonitor monitor, IProject p, ProjectSystemFolder[] folders) {
try {
if (!p.hasNature(JavaCore.NATURE_ID)) {
JavaUtils.addJavaNature(p, monitor);
@@ -111,7 +125,7 @@ public class MavenProjectUtils {
List<IClasspathEntry> list = new LinkedList<>();
ClasspathAttribute attribute = new ClasspathAttribute("maven.pomderived", Boolean.TRUE.toString());
for (ProjectSystemFolder psf : MavenSystemFolders.ALL_DIRS) {
for (ProjectSystemFolder psf : folders) {
IFolder resources = p.getFolder(psf.getPath());
if (resources.exists()) { // add the condition mostly for routines, since the resources folder might not exist
IFolder output = p.getFolder(psf.getOutputPath());
@@ -142,6 +156,7 @@ public class MavenProjectUtils {
}
}
/**
* Clear compliance settings from project, and set them into Eclipse compliance settings
*

View File

@@ -92,9 +92,13 @@ import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.runprocess.IProcessor;
import org.talend.repository.ProjectManager;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.ls.DOMImplementationLS;
import org.w3c.dom.ls.LSOutput;
import org.w3c.dom.ls.LSSerializer;
import org.xml.sax.SAXException;
/**
@@ -793,6 +797,21 @@ public class PomUtil {
}
}
public static void saveAssemblyFile(IFile assemblyFile, Document document) throws IOException {
DOMImplementation implementation = document.getImplementation();
if (implementation.hasFeature("LS", "3.0")) { //$NON-NLS-1$ //$NON-NLS-2$
DOMImplementationLS implementationLS = (DOMImplementationLS) implementation.getFeature("LS", "3.0"); //$NON-NLS-1$ //$NON-NLS-2$
LSSerializer serializer = implementationLS.createLSSerializer();
serializer.getDomConfig().setParameter("format-pretty-print", true); //$NON-NLS-1$
try (FileWriter writer = new FileWriter(assemblyFile.getLocation().toFile())) {
LSOutput output = implementationLS.createLSOutput();
output.setEncoding("UTF-8"); //$NON-NLS-1$
output.setCharacterStream(writer);
serializer.write(document, output);
}
}
}
public static void updatePomDependenciesFromProcessor(IProcessor processor) throws Exception {
// .Java project
IFile pomFile = processor.getTalendJavaProject().getProjectPom();

View File

@@ -1321,34 +1321,21 @@ public final class DBConnectionContextUtils {
}
}
// Added 20130311 TDQ-7000, when it is context mode and not general jdbc, reset the url.
if (contextType != null
&& !EDatabaseTypeName.GENERAL_JDBC
.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
String newURL = null;
if (EDatabaseTypeName.IMPALA.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
newURL =
DatabaseConnStrUtil.getImpalaString(cloneConn, cloneConn.getServerName(), cloneConn.getPort(),
cloneConn.getSID(), DbConnStrForHive.URL_HIVE_2_TEMPLATE);
} else {
newURL =
DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(), dbConn.getDbVersionString(),
server, username, password, port, sidOrDatabase, filePath.toLowerCase(), datasource,
dbRootPath, additionParam);
}
cloneConn.setURL(newURL);
return cloneConn;
}// ~
if (dbConn.getURL() != null && !dbConn.getURL().equals("") && EDatabaseTypeName.GENERAL_JDBC
.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) { //$NON-NLS-1$
if (dbConn.getURL() != null && !dbConn.getURL().equals("") //$NON-NLS-1$
&& EDatabaseTypeName.GENERAL_JDBC.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
cloneConn.setURL(url);
return cloneConn;
}
String newURL =
DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(), dbConn.getDbVersionString(), server,
username, password, port, sidOrDatabase, filePath.toLowerCase(), datasource, dbRootPath,
additionParam);
// Added 20130311 TDQ-7000, when it is context mode and not general jdbc, reset the url.
String newURL = null;
if (EDatabaseTypeName.IMPALA.equals(EDatabaseTypeName.getTypeFromDbType(dbConn.getDatabaseType()))) {
newURL = DatabaseConnStrUtil.getImpalaString(cloneConn, cloneConn.getServerName(), cloneConn.getPort(),
cloneConn.getSID(), DbConnStrForHive.URL_HIVE_2_TEMPLATE);
} else {
newURL = DatabaseConnStrUtil.getURLString(cloneConn.getDatabaseType(), dbConn.getDbVersionString(), server, username,
password, port, sidOrDatabase, filePath.toLowerCase(), datasource, dbRootPath, additionParam);
}
cloneConn.setURL(newURL);
return cloneConn;
}

View File

@@ -218,6 +218,12 @@ public final class XsdMetadataUtils {
break;
}
}
if (node == null) {
// no declaration in the present XSD
return;
}
node = populationUtil.getSchemaTree(xsdSchema, node);
orderId = 1;
loopElementFound = false;

View File

@@ -3623,6 +3623,12 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
}
@Override
public void loadProjectAndSetContext(Project project, IProject eclipseProject, boolean updateCurrentProject)
throws PersistenceException {
// nothing to do
}
public void initProjectRepository(Project project, String branchForMainProject) throws PersistenceException {
}

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
Copyright (C) 2010 Talend Inc. - www.talend.com
<!--
Copyright (C) 2010 Talend Inc. - www.talend.com
-->
<modelVersion>4.0.0</modelVersion>
@@ -36,6 +36,11 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>

View File

@@ -0,0 +1,44 @@
// ============================================================================
//
// Copyright (C) 2006-2017 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.metadata.managment.ui.utils;
import org.junit.Assert;
import org.junit.Test;
import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.impl.ConnectionFactoryImpl;
/**
* DOC cmeng class global comment. Detailled comment
*/
public class DBConnectionContextUtilsTest {
@SuppressWarnings("nls")
@Test
public void testCloneOriginalValueConnectionImpala() {
final String EXPECT_URL = "jdbc:hive2://tal-qa146.talend.lan:21050/default;principal=impala/tal-qa146.talend.lan@CDH.ONE";
DatabaseConnection originalConn = ConnectionFactoryImpl.eINSTANCE.createDatabaseConnection();
originalConn.setDatabaseType(EDatabaseTypeName.IMPALA.getXmlName());
originalConn.setServerName("tal-qa146.talend.lan");
originalConn.setPort("21050");
originalConn.setSID("default");
originalConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB, Boolean.TRUE.toString());
originalConn.getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
"impala/tal-qa146.talend.lan@CDH.ONE");
DatabaseConnection clonedConn = DBConnectionContextUtils.cloneOriginalValueConnection(originalConn, false, null);
Assert.assertEquals(EXPECT_URL, clonedConn.getURL());
}
}