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

Maven artifacts update

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