Compare commits
4 Commits
release/7.
...
release/7.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a24f07710 | ||
|
|
43cdc97d1e | ||
|
|
f1c40a3920 | ||
|
|
b47a7b2067 |
@@ -2199,6 +2199,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
updateService.syncComponentM2Jars(currentMonitor);
|
||||
updateService.installComponents(currentMonitor);
|
||||
}
|
||||
|
||||
// init sdk component
|
||||
|
||||
@@ -26,5 +26,7 @@ public interface IUpdateService extends IService {
|
||||
public String getSharedStudioMissingPatchVersion();
|
||||
|
||||
public boolean updateArtifactsFileSha256Hex(IProgressMonitor monitor, String studioArtifactsFileShaCodeHex);
|
||||
|
||||
public void installComponents(IProgressMonitor monitor);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ Export-Package: org.talend.core,
|
||||
org.talend.core.services.resource,
|
||||
org.talend.core.views,
|
||||
org.talend.designer.runprocess
|
||||
Import-Package: org.apache.commons.collections4.map
|
||||
Import-Package: org.apache.commons.collections4.map,
|
||||
org.eclipse.m2e.core,
|
||||
org.eclipse.m2e.core.embedder
|
||||
Bundle-ClassPath: .,
|
||||
lib/log4j-api-2.17.1.jar,
|
||||
lib/log4j-core-2.17.1.jar
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 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.core.model.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.spi.LoggerFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.m2e.core.embedder.IMaven;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.i18n.Messages;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
abstract public class BaseComponentInstallerTask implements IComponentInstallerTask {
|
||||
|
||||
private static final String SYS_PROP_TCOMPV0 = "tcompv0.update";
|
||||
private static final String SYS_PROP_OVERWRITE = "m2.overwrite";
|
||||
private static final String SYS_PROP_OVERWRITE_DEFAULT = Boolean.FALSE.toString();
|
||||
|
||||
private static final String SYS_CUSTOM_MAVEN_REPO = "maven.local.repository";
|
||||
|
||||
private int order;
|
||||
|
||||
private int componentType = -1;
|
||||
|
||||
private Set<ComponentGAV> gavs = new HashSet<ComponentGAV>();
|
||||
|
||||
protected boolean overWriteM2() {
|
||||
/**
|
||||
* force to overwrite, since need to sync maven-metadata-local.xml
|
||||
*/
|
||||
String prop = System.getProperty(SYS_PROP_OVERWRITE, Boolean.TRUE.toString());
|
||||
return Boolean.valueOf(prop);
|
||||
}
|
||||
|
||||
protected boolean updateTcompv0() {
|
||||
String prop = System.getProperty(SYS_PROP_TCOMPV0, SYS_PROP_OVERWRITE_DEFAULT);
|
||||
return Boolean.valueOf(prop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComponentType() {
|
||||
return componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComponentType(int componentType) {
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrder(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ComponentGAV> getComponentGAV() {
|
||||
return gavs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addComponentGAV(ComponentGAV gav) {
|
||||
gavs.add(gav);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ComponentGAV> getComponentGAV(int componentType) {
|
||||
return this.gavs.stream().filter(gav -> (gav.getComponentType() & componentType) > 0)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get implementation class of installer
|
||||
*
|
||||
* @return implementation class of installer
|
||||
*/
|
||||
abstract protected Class<? extends BaseComponentInstallerTask> getInstallerClass();
|
||||
|
||||
/**
|
||||
* Get jar file directory
|
||||
*
|
||||
* @return jar file directory
|
||||
*/
|
||||
protected File getJarFileDir() {
|
||||
URL jarFolder = FileLocator.find(FrameworkUtil.getBundle(getInstallerClass()), new Path("repository"), null);
|
||||
File jarFileDir = null;
|
||||
if (jarFolder != null) {
|
||||
try {
|
||||
jarFileDir = new File(FileLocator.toFileURL(jarFolder).getPath());
|
||||
|
||||
if (jarFileDir.isDirectory()) {
|
||||
return jarFileDir;
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
*Implementation of unzipping files into studio local m2 directory
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
@Override
|
||||
public boolean needInstall() {
|
||||
|
||||
if (this.updateTcompv0()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean toInstall = false;
|
||||
Set<ComponentGAV> tcompv0Gavs = this.getComponentGAV(COMPONENT_TYPE_TCOMPV0);
|
||||
|
||||
ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
if (librairesManagerService != null) {
|
||||
for (ComponentGAV gav : tcompv0Gavs) {
|
||||
File jarFile = librairesManagerService.resolveStatusLocally(gav.toMavenUri());
|
||||
if (jarFile == null) {
|
||||
toInstall = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (toInstall) {
|
||||
}
|
||||
return toInstall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean install(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
|
||||
if (!this.needInstall()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File jarDir = getJarFileDir();
|
||||
|
||||
if (jarDir == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File m2Dir = getM2RepositoryPath();
|
||||
if (m2Dir == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
File[] files = jarDir.listFiles();
|
||||
Set<File> zipFiles = Stream.of(files).filter(f -> f.getName().endsWith(".zip")).collect(Collectors.toSet());
|
||||
boolean installed = true;
|
||||
|
||||
monitor.beginTask(Messages.getString("BaseComponentInstallerTask.installComponent", getMonitorText()),
|
||||
zipFiles.size());
|
||||
|
||||
for (File zf : zipFiles) {
|
||||
try {
|
||||
FilesUtils.unzip(zf.getAbsolutePath(), m2Dir.getAbsolutePath(), this.overWriteM2());
|
||||
} catch (Exception e) {
|
||||
installed = false;
|
||||
}
|
||||
monitor.worked(1);
|
||||
}
|
||||
|
||||
return installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get studio local maven repository path
|
||||
*
|
||||
* @return local maven repository path
|
||||
*/
|
||||
protected File getM2RepositoryPath() {
|
||||
|
||||
String mavenRepo = System.getProperty(SYS_CUSTOM_MAVEN_REPO);
|
||||
|
||||
File m2Repo = null;
|
||||
|
||||
if (StringUtils.isEmpty(mavenRepo)) {
|
||||
final IMaven maven = MavenPlugin.getMaven();
|
||||
try {
|
||||
maven.reloadSettings();
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
String localRepository = maven.getLocalRepositoryPath();
|
||||
|
||||
if (!StringUtils.isEmpty(localRepository)) {
|
||||
m2Repo = new File(localRepository);
|
||||
}
|
||||
} else {
|
||||
m2Repo = new File(mavenRepo);
|
||||
}
|
||||
|
||||
if (m2Repo != null && !m2Repo.exists()) {
|
||||
m2Repo.mkdirs();
|
||||
}
|
||||
return m2Repo;
|
||||
}
|
||||
|
||||
protected String getMonitorText() {
|
||||
Set<ComponentGAV> tcompv0Gavs = this.getComponentGAV(COMPONENT_TYPE_TCOMPV0);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
tcompv0Gavs.forEach(gav -> {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(gav.getArtifactId());
|
||||
});
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 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.core.model.utils;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
|
||||
public class ComponentGAV {
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String classifier;
|
||||
|
||||
private String type;
|
||||
|
||||
private int componentType;
|
||||
|
||||
/**
|
||||
* @return the groupId
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupId the groupId to set
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the artifactId
|
||||
*/
|
||||
public String getArtifactId() {
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param artifactId the artifactId to set
|
||||
*/
|
||||
public void setArtifactId(String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version the version to set
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the classifier
|
||||
*/
|
||||
public String getClassifier() {
|
||||
return classifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param classifier the classifier to set
|
||||
*/
|
||||
public void setClassifier(String classifier) {
|
||||
this.classifier = classifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the componentType
|
||||
*/
|
||||
public int getComponentType() {
|
||||
return componentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param componentType the componentType to set
|
||||
*/
|
||||
public void setComponentType(int componentType) {
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
public String toMavenUri() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("mvn:");
|
||||
sb.append(toStr("/"));
|
||||
|
||||
sb.append("/");
|
||||
if (!StringUtils.isEmpty(type)) {
|
||||
sb.append(type);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String toCoordinateStr() {
|
||||
return toStr(":");
|
||||
}
|
||||
|
||||
private String toStr(String sep) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
if (!StringUtils.isEmpty(groupId)) {
|
||||
sb.append(this.groupId);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(artifactId)) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(sep);
|
||||
}
|
||||
sb.append(this.artifactId);
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(version)) {
|
||||
sb.append(sep);
|
||||
sb.append(this.version);
|
||||
}
|
||||
if (!StringUtils.isEmpty(classifier)) {
|
||||
sb.append(sep);
|
||||
sb.append(this.classifier);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ComponentGAV)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ComponentGAV thatObj = (ComponentGAV) obj;
|
||||
|
||||
if (!StringUtils.equals(this.getGroupId(), thatObj.getGroupId())) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getArtifactId(), thatObj.getArtifactId())) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getVersion(), thatObj.getVersion())) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getType(), thatObj.getType())) {
|
||||
return false;
|
||||
}
|
||||
if (!StringUtils.equals(this.getClassifier(), thatObj.getClassifier())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.getComponentType() == thatObj.getComponentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (this.getGroupId() == null ? 0 : this.getGroupId().hashCode());
|
||||
result = prime * result + (this.getArtifactId() == null ? 0 : this.getArtifactId().hashCode());
|
||||
result = prime * result + (this.getVersion() == null ? 0 : this.getVersion().hashCode());
|
||||
result = prime * result + (this.getType() == null ? 0 : this.getType().hashCode());
|
||||
result = prime * result + (this.getClassifier() == null ? 0 : this.getClassifier().hashCode());
|
||||
result = prime * result + this.getComponentType();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GAV [groupId=" + this.groupId + ", artifactId=" + this.artifactId + ", version=" + this.version + ", classifier=" + this.classifier + ", type=" + this.type + ", componentType="
|
||||
+ this.componentType + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 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.core.model.utils;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
|
||||
public interface IComponentInstallerTask {
|
||||
|
||||
int COMPONENT_TYPE_TCOMPV0 = 1;
|
||||
|
||||
int COMPONENT_TYPE_TCOMPV1 = 2;
|
||||
|
||||
int COMPONENT_TYPE_MAVEN_REPO = 4;
|
||||
|
||||
/**
|
||||
* Order of the task, smaller means higher priority
|
||||
*
|
||||
* @return Order of the task
|
||||
*/
|
||||
int getOrder();
|
||||
|
||||
/**
|
||||
* Set order of the task
|
||||
*
|
||||
* @param order
|
||||
*/
|
||||
void setOrder(int order);
|
||||
|
||||
/**
|
||||
* Get all component gavs
|
||||
*
|
||||
* @return Set<ComponentGAV>
|
||||
*/
|
||||
Set<ComponentGAV> getComponentGAV();
|
||||
|
||||
/**
|
||||
* @param componentType 1 - tcompv0, 2 - tcompv1
|
||||
* @return Set<ComponentGAV>
|
||||
*/
|
||||
Set<ComponentGAV> getComponentGAV(int componentType);
|
||||
|
||||
/**
|
||||
* Add component gav
|
||||
*
|
||||
* @param gav
|
||||
*/
|
||||
void addComponentGAV(ComponentGAV gav);
|
||||
|
||||
/**
|
||||
* Whether it is necessary to install the component
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean needInstall();
|
||||
|
||||
/**
|
||||
* Install the component
|
||||
*
|
||||
* @param monitor
|
||||
* @throws InvocationTargetException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
boolean install(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
|
||||
|
||||
/**
|
||||
* @return the componentType
|
||||
*/
|
||||
int getComponentType();
|
||||
|
||||
/**
|
||||
* @param componentType the componentType to set
|
||||
*/
|
||||
void setComponentType(int componentType);
|
||||
}
|
||||
@@ -126,7 +126,42 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
<version>2.22.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-annotations</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-api</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-booter</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit4</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>studio-tacokit-dependencies</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<tacokit.components.version>1.27.24</tacokit.components.version>
|
||||
<tacokit.components.version>1.27.25</tacokit.components.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<version>2.22.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
@@ -190,6 +190,16 @@
|
||||
<version>3.0.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.shared</groupId>
|
||||
<artifactId>maven-shared-utils</artifactId>
|
||||
<version>3.3.3</version>
|
||||
|
||||
@@ -5,4 +5,5 @@ bin.includes = META-INF/,\
|
||||
schema/,\
|
||||
plugin.xml,\
|
||||
OSGI-INF/,\
|
||||
repository/,\
|
||||
icons/
|
||||
|
||||
@@ -9,4 +9,119 @@
|
||||
</parent>
|
||||
<artifactId>org.talend.updates.runtime</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.sonatype.plexus</groupId>
|
||||
<artifactId>plexus-cipher</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.surefire</groupId>
|
||||
<artifactId>surefire-junit4</artifactId>
|
||||
<version>2.22.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-annotations</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>${project.basedir}/repository</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>${project.basedir}/tmp</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies-jar</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/tmp</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
<useRepositoryLayout>true</useRepositoryLayout>
|
||||
<addParentPoms>true</addParentPoms>
|
||||
<copyPom>true</copyPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>zip-maven-repository</id>
|
||||
<phase>generate-sources</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<zip destfile="${project.basedir}/repository/maven_repository.zip" basedir="${project.basedir}/tmp/" />
|
||||
<delete dir="${project.basedir}/tmp/" />
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
2
main/plugins/org.talend.updates.runtime/repository/.gitignore
vendored
Normal file
2
main/plugins/org.talend.updates.runtime/repository/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.zip
|
||||
*.properties
|
||||
@@ -0,0 +1,124 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2023 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.updates.runtime.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.utils.BaseComponentInstallerTask;
|
||||
import org.talend.core.model.utils.ComponentGAV;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.updates.runtime.UpdatesRuntimePlugin;
|
||||
import org.talend.utils.files.FileUtils;
|
||||
|
||||
|
||||
public class M2repoBaseInstaller extends BaseComponentInstallerTask {
|
||||
|
||||
private static final String PLUGIN_GROUP = "org.talend.studio";
|
||||
|
||||
private static final String SYS_PROP_M2 = "m2.update";
|
||||
|
||||
protected boolean updateM2() {
|
||||
String prop = System.getProperty(SYS_PROP_M2, "true");
|
||||
return Boolean.valueOf(prop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean needInstall() {
|
||||
|
||||
if (this.updateM2()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ComponentGAV gav = this.getPluginGAV();
|
||||
|
||||
ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
|
||||
if (librairesManagerService != null) {
|
||||
File f = librairesManagerService.resolveStatusLocally(gav.toMavenUri());
|
||||
if (f == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean install(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
boolean ret = super.install(monitor);
|
||||
|
||||
if (ret) {
|
||||
// install pom
|
||||
File tempFolder = FileUtils.createTmpFolder("generate", "pom");
|
||||
|
||||
ComponentGAV gav = this.getPluginGAV();
|
||||
|
||||
MavenArtifact art = new MavenArtifact();
|
||||
art.setGroupId(gav.getGroupId());
|
||||
art.setArtifactId(gav.getArtifactId());
|
||||
art.setVersion(gav.getVersion());
|
||||
art.setType(gav.getType());
|
||||
|
||||
try {
|
||||
String pomPath = PomUtil.generatePomInFolder(tempFolder, art);
|
||||
|
||||
TalendMavenResolver.upload(art.getGroupId(), art.getArtifactId(), art.getClassifier(), TalendMavenConstants.PACKAGING_POM, art.getVersion(), new File(pomPath));
|
||||
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMonitorText() {
|
||||
ComponentGAV gav = this.getPluginGAV();
|
||||
return gav.getArtifactId();
|
||||
}
|
||||
|
||||
protected ComponentGAV getPluginGAV() {
|
||||
Bundle bundle = FrameworkUtil.getBundle(getInstallerClass());
|
||||
String[] bundleName = bundle.getSymbolicName().split("\\.");
|
||||
String artifactId = bundleName[bundleName.length - 1];
|
||||
if (bundleName.length > 1) {
|
||||
artifactId = bundleName[bundleName.length - 2] + "-" + bundleName[bundleName.length - 1];
|
||||
}
|
||||
|
||||
ComponentGAV gav = new ComponentGAV();
|
||||
gav.setGroupId(PLUGIN_GROUP);
|
||||
gav.setArtifactId(artifactId);
|
||||
gav.setVersion(bundle.getVersion().toString());
|
||||
gav.setType(TalendMavenConstants.PACKAGING_POM);
|
||||
return gav;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Class<? extends BaseComponentInstallerTask> getInstallerClass() {
|
||||
return M2repoBaseInstaller.class;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,17 +17,19 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.resource.FileExtensions;
|
||||
import org.talend.core.nexus.ArtifactRepositoryBean;
|
||||
import org.talend.core.runtime.util.SharedStudioUtils;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.updates.runtime.engine.component.InstallComponentMessages;
|
||||
import org.talend.updates.runtime.engine.factory.ComponentsLocalNexusInstallFactory;
|
||||
import org.talend.updates.runtime.maven.M2repoBaseInstaller;
|
||||
import org.talend.updates.runtime.maven.MavenRepoSynchronizer;
|
||||
import org.talend.updates.runtime.model.ExtraFeature;
|
||||
import org.talend.updates.runtime.model.FeatureCategory;
|
||||
@@ -158,5 +160,17 @@ public class UpdateService implements IUpdateService {
|
||||
public boolean updateArtifactsFileSha256Hex(IProgressMonitor monitor, String studioArtifactsFileShaCodeHex) {
|
||||
return SharedStudioPatchInfoProvider.getInstance().updateArtifactsFileSha256Hex(studioArtifactsFileShaCodeHex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and install components
|
||||
*/
|
||||
public void installComponents(IProgressMonitor monitor) {
|
||||
M2repoBaseInstaller installer = new M2repoBaseInstaller();
|
||||
try {
|
||||
installer.install(monitor);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user