提交 00eac0b4 编写于 作者: J jurgen

Maven artifacts update

Former-commit-id: 803043a8
上级 eeb26894
......@@ -956,7 +956,7 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException
{
try {
file.downloadLibraryFile(monitor);
file.downloadLibraryFile(monitor, false);
} catch (final Exception e) {
log.warn("Can't obtain driver license", e);
}
......
......@@ -323,10 +323,10 @@ public class DriverFileDescriptor implements DBPDriverFile
}
*/
public void downloadLibraryFile(DBRProgressMonitor monitor) throws IOException, InterruptedException
public void downloadLibraryFile(DBRProgressMonitor monitor, boolean updateVersion) throws IOException, InterruptedException
{
if (isMavenArtifact()) {
downloadMavenArtifact(monitor);
downloadMavenArtifact(monitor, updateVersion);
}
String externalURL = getExternalURL();
if (externalURL == null) {
......@@ -386,16 +386,23 @@ public class DriverFileDescriptor implements DBPDriverFile
monitor.done();
}
private void downloadMavenArtifact(DBRProgressMonitor monitor) throws IOException {
private void downloadMavenArtifact(DBRProgressMonitor monitor, boolean updateVersion) throws IOException {
MavenArtifactReference artifactInfo = new MavenArtifactReference(path);
if (updateVersion) {
MavenRegistry.getInstance().resetArtifactInfo(artifactInfo);
}
MavenArtifact artifact = MavenRegistry.getInstance().findArtifact(artifactInfo);
if (artifact == null) {
throw new IOException("Maven artifact '" + path + "' not found");
}
MavenLocalVersion localVersion = artifact.getActiveLocalVersion();
if (localVersion != null && localVersion.getCacheFile().exists()) {
// Already cached
return;
if (updateVersion) {
artifact.loadMetadata();
} else {
MavenLocalVersion localVersion = artifact.getActiveLocalVersion();
if (localVersion != null && localVersion.getCacheFile().exists()) {
// Already cached
return;
}
}
artifact.resolveVersion(monitor, artifactInfo.getVersion());
}
......
......@@ -131,6 +131,17 @@ public class MavenRegistry
return null;
}
public void resetArtifactInfo(MavenArtifactReference artifactReference) {
String groupId = artifactReference.getGroupId();
String artifactId = artifactReference.getArtifactId();
String fullId = groupId + ":" + artifactId;
notFoundArtifacts.remove(fullId);
for (MavenRepository repository : repositories) {
repository.resetArtifactCache(groupId, artifactId);
}
localRepository.resetArtifactCache(groupId, artifactId);
}
@Nullable
private MavenArtifact findInRepositories(@NotNull String groupId, @NotNull String artifactId, boolean resolve) {
// Try all available repositories (without resolve)
......@@ -155,4 +166,5 @@ public class MavenRegistry
}
return null;
}
}
......@@ -34,6 +34,7 @@ import org.xml.sax.Attributes;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
/**
......@@ -133,6 +134,15 @@ public class MavenRepository
return null;
}
void resetArtifactCache(@NotNull String groupId, @NotNull String artifactId) {
for (Iterator<MavenArtifact> iterator = cachedArtifacts.iterator(); iterator.hasNext(); ) {
MavenArtifact artifact = iterator.next();
if (artifact.getGroupId().equals(groupId) && artifact.getArtifactId().equals(artifactId)) {
iterator.remove();
}
}
}
private synchronized void addCachedArtifact(@NotNull MavenArtifact artifact) {
cachedArtifacts.add(artifact);
// saveCache();
......
......@@ -127,7 +127,7 @@ class DriverDownloadAutoPage extends DriverDownloadPage {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
file.downloadLibraryFile(monitor);
file.downloadLibraryFile(monitor, getWizard().isUpdateVersion());
} catch (IOException e) {
throw new InvocationTargetException(e);
}
......
......@@ -62,6 +62,10 @@ public class DriverDownloadWizard extends Wizard implements IExportWizard {
return forceDownload;
}
public boolean isUpdateVersion() {
return updateVersion;
}
private void loadSettings()
{
IDialogSettings section = UIUtils.getDialogSettings(DRIVER_DOWNLOAD_DIALOG_SETTINGS);
......
......@@ -480,6 +480,7 @@ public class DriverEditDialog extends HelpEnabledDialog
@Override
public void widgetSelected(SelectionEvent e) {
DriverDownloadDialog.updateDriverFiles(getShell(), driver, libList, true);
changeLibContent();
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册