mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Maven: auto downloading of sources and javadoc + parallel downloading
This commit is contained in:
+26
-10
@@ -51,13 +51,12 @@ import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.plugin.PluginManager;
|
||||
import org.apache.maven.profiles.DefaultProfileManager;
|
||||
import org.apache.maven.profiles.ProfileManager;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.*;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.artifact.ProjectArtifactFactory;
|
||||
import org.apache.maven.project.interpolation.AbstractStringBasedModelInterpolator;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolator;
|
||||
import org.apache.maven.project.interpolation.StringSearchModelInterpolator;
|
||||
import org.apache.maven.project.path.DefaultPathTranslator;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.settings.Mirror;
|
||||
@@ -72,6 +71,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.maven.project.*;
|
||||
import org.jetbrains.idea.maven.utils.MavenLog;
|
||||
import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
@@ -292,6 +292,30 @@ public class MavenEmbedderWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
public Artifact resolve(@NotNull final MavenId id,
|
||||
@NotNull final String type,
|
||||
@Nullable final String classifier,
|
||||
@NotNull final List<MavenRemoteRepository> remoteRepositories)
|
||||
throws MavenProcessCanceledException {
|
||||
return doExecute(new Executor<Artifact>() {
|
||||
public Artifact execute() throws Exception {
|
||||
Artifact artifact = getComponent(ArtifactFactory.class).createArtifactWithClassifier(id.getGroupId(),
|
||||
id.getArtifactId(),
|
||||
id.getVersion(),
|
||||
type,
|
||||
classifier);
|
||||
try {
|
||||
getComponent(ArtifactResolver.class).resolve(artifact, convertRepositories(remoteRepositories), myLocalRepository);
|
||||
return artifact;
|
||||
}
|
||||
catch (Exception e) {
|
||||
MavenLog.LOG.info(e);
|
||||
}
|
||||
return artifact;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<ArtifactRepository> convertRepositories(List<MavenRemoteRepository> repositories) {
|
||||
List<ArtifactRepository> result = new ArrayList<ArtifactRepository>();
|
||||
for (MavenRemoteRepository each : repositories) {
|
||||
@@ -326,14 +350,6 @@ public class MavenEmbedderWrapper {
|
||||
});
|
||||
}
|
||||
|
||||
public Artifact createArtifact(String groupId, String artifactId, String version, String type, String classifier) {
|
||||
return getComponent(ArtifactFactory.class).createArtifactWithClassifier(groupId,
|
||||
artifactId,
|
||||
version,
|
||||
type,
|
||||
classifier);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MavenExecutionResult execute(@NotNull final VirtualFile file,
|
||||
@NotNull final Collection<String> activeProfiles,
|
||||
|
||||
+4
-4
@@ -226,8 +226,8 @@ public class MavenRootModelAdapter {
|
||||
Library.ModifiableModel libraryModel = provider.getLibraryModel(library);
|
||||
|
||||
setUrl(libraryModel, OrderRootType.CLASSES, artifact, null);
|
||||
setUrl(libraryModel, OrderRootType.SOURCES, artifact, MavenConstants.SOURCES_CLASSIFIER);
|
||||
setUrl(libraryModel, JavadocOrderRootType.getInstance(), artifact, MavenConstants.JAVADOC_CLASSIFIER);
|
||||
setUrl(libraryModel, OrderRootType.SOURCES, artifact, MavenConstants.CLASSIFIER_SOURCES);
|
||||
setUrl(libraryModel, JavadocOrderRootType.getInstance(), artifact, MavenConstants.CLASSIFIER_JAVADOC);
|
||||
|
||||
LibraryOrderEntry e = myRootModel.addLibraryEntry(library);
|
||||
e.setExported(isExportable);
|
||||
@@ -265,8 +265,8 @@ public class MavenRootModelAdapter {
|
||||
String path = classes.substring(0, dotPos);
|
||||
|
||||
String jarSuffix = ".jar" + JarFileSystem.JAR_SEPARATOR;
|
||||
String sourcesPath = path + "-" + MavenConstants.SOURCES_CLASSIFIER + jarSuffix;
|
||||
String javadocPath = path + "-" + MavenConstants.JAVADOC_CLASSIFIER + jarSuffix;
|
||||
String sourcesPath = path + "-" + MavenConstants.CLASSIFIER_SOURCES + jarSuffix;
|
||||
String javadocPath = path + "-" + MavenConstants.CLASSIFIER_JAVADOC + jarSuffix;
|
||||
|
||||
for (String each : library.getUrls(OrderRootType.SOURCES)) {
|
||||
if (!FileUtil.pathsEqual(each, sourcesPath)) return true;
|
||||
|
||||
+62
-33
@@ -21,13 +21,18 @@ import gnu.trove.THashMap;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.jetbrains.idea.maven.embedder.MavenEmbedderWrapper;
|
||||
import org.jetbrains.idea.maven.utils.MavenConstants;
|
||||
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
|
||||
import org.jetbrains.idea.maven.utils.MavenLog;
|
||||
import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MavenArtifactDownloader {
|
||||
private final static ExecutorService EXECUTOR = new ThreadPoolExecutor(0, 5, 1, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(5));
|
||||
|
||||
private final MavenEmbedderWrapper myEmbedder;
|
||||
private final MavenProgressIndicator myProgress;
|
||||
private final MavenProjectsTree myProjectsTree;
|
||||
@@ -35,10 +40,10 @@ public class MavenArtifactDownloader {
|
||||
|
||||
public static void download(MavenProjectsTree projectsTree,
|
||||
List<MavenProject> mavenProjects,
|
||||
boolean demand,
|
||||
MavenEmbedderWrapper embedder,
|
||||
boolean downloadSources,
|
||||
boolean downloadJavadoc, MavenEmbedderWrapper embedder,
|
||||
MavenProgressIndicator p) throws MavenProcessCanceledException {
|
||||
new MavenArtifactDownloader(projectsTree, mavenProjects, embedder, p).download(demand);
|
||||
new MavenArtifactDownloader(projectsTree, mavenProjects, embedder, p).download(downloadSources, downloadJavadoc);
|
||||
}
|
||||
|
||||
private MavenArtifactDownloader(MavenProjectsTree projectsTree,
|
||||
@@ -51,13 +56,12 @@ public class MavenArtifactDownloader {
|
||||
myProgress = p;
|
||||
}
|
||||
|
||||
private void download(boolean demand) throws MavenProcessCanceledException {
|
||||
private void download(boolean downloadSources, boolean downloadJavadoc) throws MavenProcessCanceledException {
|
||||
List<File> downloadedFiles = new ArrayList<File>();
|
||||
try {
|
||||
Map<MavenArtifact, Set<MavenRemoteRepository>> artifacts = collectArtifactsToDownload();
|
||||
Map<MavenId, Set<MavenRemoteRepository>> artifacts = collectArtifactsToDownload();
|
||||
|
||||
download(MavenConstants.SOURCES_CLASSIFIER, artifacts, downloadedFiles);
|
||||
download(MavenConstants.JAVADOC_CLASSIFIER, artifacts, downloadedFiles);
|
||||
download(downloadSources, downloadJavadoc, artifacts, downloadedFiles);
|
||||
}
|
||||
finally {
|
||||
scheduleFilesRefresh(downloadedFiles);
|
||||
@@ -80,21 +84,23 @@ public class MavenArtifactDownloader {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<MavenArtifact, Set<MavenRemoteRepository>> collectArtifactsToDownload() {
|
||||
Map<MavenArtifact, Set<MavenRemoteRepository>> result = new THashMap<MavenArtifact, Set<MavenRemoteRepository>>();
|
||||
private Map<MavenId, Set<MavenRemoteRepository>> collectArtifactsToDownload() {
|
||||
Map<MavenId, Set<MavenRemoteRepository>> result = new THashMap<MavenId, Set<MavenRemoteRepository>>();
|
||||
|
||||
for (MavenProject each : myMavenProjects) {
|
||||
List<MavenRemoteRepository> repositories = each.getRemoteRepositories();
|
||||
for (MavenProject eachProject : myMavenProjects) {
|
||||
List<MavenRemoteRepository> repositories = eachProject.getRemoteRepositories();
|
||||
|
||||
for (MavenArtifact eachDependency : each.getDependencies()) {
|
||||
if (!each.isSupportedDependency(eachDependency)) continue;
|
||||
for (MavenArtifact eachDependency : eachProject.getDependencies()) {
|
||||
if (Artifact.SCOPE_SYSTEM.equalsIgnoreCase(eachDependency.getScope())) continue;
|
||||
if (myProjectsTree.findProject(eachDependency.getMavenId()) != null) continue;
|
||||
if (!eachProject.isSupportedDependency(eachDependency)) continue;
|
||||
if (!eachDependency.isResolved()) continue;
|
||||
|
||||
Set<MavenRemoteRepository> registeredRepositories = result.get(eachDependency);
|
||||
MavenId depId = eachDependency.getMavenId();
|
||||
Set<MavenRemoteRepository> registeredRepositories = result.get(depId);
|
||||
if (registeredRepositories == null) {
|
||||
registeredRepositories = new LinkedHashSet<MavenRemoteRepository>();
|
||||
result.put(eachDependency, registeredRepositories);
|
||||
result.put(depId, registeredRepositories);
|
||||
}
|
||||
registeredRepositories.addAll(repositories);
|
||||
}
|
||||
@@ -102,26 +108,49 @@ public class MavenArtifactDownloader {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void download(String classifier,
|
||||
Map<MavenArtifact, Set<MavenRemoteRepository>> libraryArtifacts,
|
||||
List<File> downloadedFiles) throws MavenProcessCanceledException {
|
||||
myProgress.setText(ProjectBundle.message("maven.downloading.artifact", classifier));
|
||||
private void download(final boolean downloadSources,
|
||||
final boolean downloadJavadoc,
|
||||
final Map<MavenId, Set<MavenRemoteRepository>> libraryArtifacts,
|
||||
final List<File> downloadedFiles) throws MavenProcessCanceledException {
|
||||
List<Future<?>> futures = new ArrayList<Future<?>>();
|
||||
|
||||
int step = 0;
|
||||
for (Map.Entry<MavenArtifact, Set<MavenRemoteRepository>> eachEntry : libraryArtifacts.entrySet()) {
|
||||
MavenArtifact eachArtifact = eachEntry.getKey();
|
||||
List<String> classifiers = new ArrayList<String>(2);
|
||||
if (downloadSources) classifiers.add(MavenConstants.CLASSIFIER_SOURCES);
|
||||
if (downloadJavadoc) classifiers.add(MavenConstants.CLASSIFIER_JAVADOC);
|
||||
|
||||
myProgress.checkCanceled();
|
||||
myProgress.setFraction(((double)step++) / libraryArtifacts.size());
|
||||
myProgress.setText2(eachArtifact.toString());
|
||||
final AtomicInteger downloaded = new AtomicInteger();
|
||||
final int total = libraryArtifacts.size() * classifiers.size();
|
||||
try {
|
||||
for (final Map.Entry<MavenId, Set<MavenRemoteRepository>> eachEntry : libraryArtifacts.entrySet()) {
|
||||
myProgress.checkCanceled();
|
||||
|
||||
Artifact a = myEmbedder.createArtifact(eachArtifact.getGroupId(),
|
||||
eachArtifact.getArtifactId(),
|
||||
eachArtifact.getVersion(),
|
||||
MavenConstants.TYPE_JAR,
|
||||
classifier);
|
||||
myEmbedder.resolve(a, new ArrayList<MavenRemoteRepository>(eachEntry.getValue()));
|
||||
if (a.isResolved()) downloadedFiles.add(a.getFile());
|
||||
for (final String eachClassifier : classifiers) {
|
||||
futures.add(EXECUTOR.submit(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
myProgress.checkCanceled();
|
||||
myProgress.setFraction(((double)downloaded.getAndIncrement()) / total);
|
||||
|
||||
Artifact a = myEmbedder.resolve(eachEntry.getKey(), MavenConstants.TYPE_JAR, eachClassifier,
|
||||
new ArrayList<MavenRemoteRepository>(eachEntry.getValue()));
|
||||
if (a.isResolved()) downloadedFiles.add(a.getFile());
|
||||
}
|
||||
catch (MavenProcessCanceledException ignore) {
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
for (Future<?> each : futures) {
|
||||
try {
|
||||
each.get();
|
||||
}
|
||||
catch (Exception e) {
|
||||
MavenLog.LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -65,5 +65,4 @@ public class MavenImportingConfigurable implements Configurable {
|
||||
public String getHelpTopic() {
|
||||
return "reference.settings.project.maven.importing";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-4
@@ -20,9 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Kaznacheev
|
||||
*/
|
||||
public class MavenImportingSettings implements Cloneable {
|
||||
private static final String PROCESS_RESOURCES_PHASE = "process-resources";
|
||||
public static final String[] UPDATE_FOLDERS_PHASES = new String[]{
|
||||
@@ -45,6 +42,9 @@ public class MavenImportingSettings implements Cloneable {
|
||||
private boolean useMavenOutput = true;
|
||||
private String updateFoldersOnImportPhase = UPDATE_FOLDERS_DEFAULT_PHASE;
|
||||
|
||||
private boolean downloadSourcesAutomatically = false;
|
||||
private boolean downloadJavadocAutomatically = false;
|
||||
|
||||
private List<Listener> myListeners = ContainerUtil.createEmptyCOWList();
|
||||
|
||||
@NotNull
|
||||
@@ -107,6 +107,22 @@ public class MavenImportingSettings implements Cloneable {
|
||||
this.updateFoldersOnImportPhase = updateFoldersOnImportPhase;
|
||||
}
|
||||
|
||||
public boolean shouldDownloadSourcesAutomatically() {
|
||||
return downloadSourcesAutomatically;
|
||||
}
|
||||
|
||||
public void setDownloadSourcesAutomatically(boolean Value) {
|
||||
this.downloadSourcesAutomatically = Value;
|
||||
}
|
||||
|
||||
public boolean shouldDownloadJavadocAutomatically() {
|
||||
return downloadJavadocAutomatically;
|
||||
}
|
||||
|
||||
public void setDownloadJavadocAutomatically(boolean value) {
|
||||
this.downloadJavadocAutomatically = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -114,9 +130,11 @@ public class MavenImportingSettings implements Cloneable {
|
||||
|
||||
MavenImportingSettings that = (MavenImportingSettings)o;
|
||||
|
||||
if (importAutomatically != that.importAutomatically) return false;
|
||||
if (createModuleGroups != that.createModuleGroups) return false;
|
||||
if (createModulesForAggregators != that.createModulesForAggregators) return false;
|
||||
if (importAutomatically != that.importAutomatically) return false;
|
||||
if (downloadJavadocAutomatically != that.downloadJavadocAutomatically) return false;
|
||||
if (downloadSourcesAutomatically != that.downloadSourcesAutomatically) return false;
|
||||
if (lookForNested != that.lookForNested) return false;
|
||||
if (useMavenOutput != that.useMavenOutput) return false;
|
||||
if (!dedicatedModuleDir.equals(that.dedicatedModuleDir)) return false;
|
||||
@@ -138,6 +156,8 @@ public class MavenImportingSettings implements Cloneable {
|
||||
result = 31 * result + (createModuleGroups ? 1 : 0);
|
||||
result = 31 * result + (useMavenOutput ? 1 : 0);
|
||||
result = 31 * result + (updateFoldersOnImportPhase != null ? updateFoldersOnImportPhase.hashCode() : 0);
|
||||
result = 31 * result + (downloadSourcesAutomatically ? 1 : 0);
|
||||
result = 31 * result + (downloadJavadocAutomatically ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+40
-3
@@ -1,16 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.maven.project.MavenImportingSettingsForm">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="10" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="11" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="457" height="306"/>
|
||||
<xy x="20" y="20" width="457" height="401"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="5d738">
|
||||
<constraints>
|
||||
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="9a961" class="javax.swing.JCheckBox" binding="mySeparateModulesDirCheckBox" default-binding="true">
|
||||
@@ -122,6 +122,43 @@
|
||||
<text value="Import Maven projects &automatically"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="49dc8" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="9" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<focusable value="true"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="62876" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Automatically download"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="42e57" class="javax.swing.JCheckBox" binding="myDownloadSourcesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<margin top="2" left="0" bottom="2" right="3"/>
|
||||
<text value="Sou&rces"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a3f2e" class="javax.swing.JCheckBox" binding="myDownloadJavadocCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Javadoc"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
|
||||
+13
-5
@@ -16,10 +16,10 @@
|
||||
package org.jetbrains.idea.maven.project;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.projectImport.ProjectFormatPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -42,9 +42,11 @@ public class MavenImportingSettingsForm {
|
||||
private JCheckBox myCreateGroupsCheckBox;
|
||||
private JComboBox myUpdateFoldersOnImportPhaseComboBox;
|
||||
private JCheckBox myUseMavenOutputCheckBox;
|
||||
private JCheckBox myDownloadSourcesCheckBox;
|
||||
private JCheckBox myDownloadJavadocCheckBox;
|
||||
|
||||
public MavenImportingSettingsForm(boolean isImportStep) {
|
||||
if(!isImportStep){
|
||||
if (!isImportStep) {
|
||||
mySearchRecursivelyCheckBox.setVisible(false);
|
||||
myProjectFormatLabel.setVisible(false);
|
||||
myProjectFormatComboBox.setVisible(false);
|
||||
@@ -60,7 +62,7 @@ public class MavenImportingSettingsForm {
|
||||
mySeparateModulesDirCheckBox.addActionListener(listener);
|
||||
|
||||
mySeparateModulesDirChooser.addBrowseFolderListener(ProjectBundle.message("maven.import.title.module.dir"), "", null,
|
||||
new FileChooserDescriptor(false, true, false, false, false, false));
|
||||
new FileChooserDescriptor(false, true, false, false, false, false));
|
||||
|
||||
myUpdateFoldersOnImportPhaseComboBox.setModel(new DefaultComboBoxModel(MavenImportingSettings.UPDATE_FOLDERS_PHASES));
|
||||
}
|
||||
@@ -94,9 +96,12 @@ public class MavenImportingSettingsForm {
|
||||
data.setCreateModulesForAggregators(myCreateModulesForAggregators.isSelected());
|
||||
data.setCreateModuleGroups(myCreateGroupsCheckBox.isSelected());
|
||||
|
||||
data.setUseMavenOutput(myUseMavenOutputCheckBox.isSelected());
|
||||
|
||||
data.setUpdateFoldersOnImportPhase((String)myUpdateFoldersOnImportPhaseComboBox.getSelectedItem());
|
||||
|
||||
data.setUseMavenOutput(myUseMavenOutputCheckBox.isSelected());
|
||||
data.setDownloadSourcesAutomatically(myDownloadSourcesCheckBox.isSelected());
|
||||
data.setDownloadJavadocAutomatically(myDownloadJavadocCheckBox.isSelected());
|
||||
}
|
||||
|
||||
public void setData(MavenImportingSettings data) {
|
||||
@@ -109,9 +114,12 @@ public class MavenImportingSettingsForm {
|
||||
myCreateModulesForAggregators.setSelected(data.isCreateModulesForAggregators());
|
||||
myCreateGroupsCheckBox.setSelected(data.isCreateModuleGroups());
|
||||
|
||||
myUseMavenOutputCheckBox.setSelected(data.isUseMavenOutput());
|
||||
|
||||
myUpdateFoldersOnImportPhaseComboBox.setSelectedItem(data.getUpdateFoldersOnImportPhase());
|
||||
|
||||
myUseMavenOutputCheckBox.setSelected(data.isUseMavenOutput());
|
||||
myDownloadSourcesCheckBox.setSelected(data.shouldDownloadSourcesAutomatically());
|
||||
myDownloadJavadocCheckBox.setSelected(data.shouldDownloadJavadocAutomatically());
|
||||
|
||||
updateControls();
|
||||
}
|
||||
|
||||
+12
-2
@@ -349,6 +349,9 @@ public class MavenProjectsManager extends SimpleProjectComponent implements Pers
|
||||
if (projectWithChanges.first.hasUnresolvedPlugins()) {
|
||||
schedulePluginsResolving(projectWithChanges.first, nativeMavenProject);
|
||||
}
|
||||
scheduleArtifactsDownloading(Collections.singleton(projectWithChanges.first),
|
||||
getImportingSettings().shouldDownloadSourcesAutomatically(),
|
||||
getImportingSettings().shouldDownloadJavadocAutomatically());
|
||||
scheduleForNextImport(projectWithChanges);
|
||||
}
|
||||
processMessage(message);
|
||||
@@ -705,16 +708,23 @@ public class MavenProjectsManager extends SimpleProjectComponent implements Pers
|
||||
});
|
||||
}
|
||||
|
||||
public void scheduleArtifactsDownloading(final Collection<MavenProject> projects) {
|
||||
public void scheduleArtifactsDownloading(final Collection<MavenProject> projects, final boolean sources, final boolean javadoc) {
|
||||
if (!sources && !javadoc) return;
|
||||
|
||||
runWhenFullyOpen(new Runnable() {
|
||||
public void run() {
|
||||
for (MavenProject each : projects) {
|
||||
myArtifactsDownloadingProcessor.scheduleTask(new MavenProjectsProcessorArtifactsDownloadingTask(each, myProjectsTree));
|
||||
myArtifactsDownloadingProcessor.scheduleTask(
|
||||
new MavenProjectsProcessorArtifactsDownloadingTask(each, myProjectsTree, sources, javadoc));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void scheduleArtifactsDownloading(final Collection<MavenProject> projects) {
|
||||
scheduleArtifactsDownloading(projects, true, true);
|
||||
}
|
||||
|
||||
public void scheduleArtifactsDownloadingForAllProjects() {
|
||||
scheduleArtifactsDownloading(getProjects());
|
||||
}
|
||||
|
||||
+9
-2
@@ -21,13 +21,20 @@ import org.jetbrains.idea.maven.utils.MavenProcessCanceledException;
|
||||
import org.jetbrains.idea.maven.utils.MavenProgressIndicator;
|
||||
|
||||
public class MavenProjectsProcessorArtifactsDownloadingTask extends MavenProjectsProcessorBasicTask {
|
||||
private final boolean myDownloadSources;
|
||||
private final boolean myDownloadJavadoc;
|
||||
|
||||
public MavenProjectsProcessorArtifactsDownloadingTask(MavenProject project,
|
||||
MavenProjectsTree tree) {
|
||||
MavenProjectsTree tree,
|
||||
boolean downloadSources,
|
||||
boolean downloadJavadoc) {
|
||||
super(project, tree);
|
||||
myDownloadSources = downloadSources;
|
||||
myDownloadJavadoc = downloadJavadoc;
|
||||
}
|
||||
|
||||
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator)
|
||||
throws MavenProcessCanceledException {
|
||||
myTree.downloadArtifacts(myMavenProject, embeddersManager, console, indicator);
|
||||
myTree.downloadArtifacts(myMavenProject, myDownloadSources, myDownloadJavadoc, embeddersManager, console, indicator);
|
||||
}
|
||||
}
|
||||
@@ -1056,6 +1056,8 @@ public class MavenProjectsTree {
|
||||
}
|
||||
|
||||
public void downloadArtifacts(MavenProject mavenProject,
|
||||
boolean downloadSources,
|
||||
boolean downloadJavadoc,
|
||||
MavenEmbeddersManager embeddersManager,
|
||||
MavenConsole console,
|
||||
MavenProgressIndicator process) throws MavenProcessCanceledException {
|
||||
@@ -1063,7 +1065,7 @@ public class MavenProjectsTree {
|
||||
embedder.customizeForResolve(console, process);
|
||||
|
||||
try {
|
||||
MavenArtifactDownloader.download(this, Collections.singletonList(mavenProject), true, embedder, process);
|
||||
MavenArtifactDownloader.download(this, Collections.singletonList(mavenProject), downloadSources, downloadJavadoc, embedder, process);
|
||||
fireArtifactsDownloaded(mavenProject);
|
||||
}
|
||||
finally {
|
||||
@@ -1080,13 +1082,8 @@ public class MavenProjectsTree {
|
||||
embedder.customizeForResolve(console, process);
|
||||
|
||||
try {
|
||||
Artifact artifact = embedder.createArtifact(id.getGroupId(),
|
||||
id.getArtifactId(),
|
||||
id.getVersion(),
|
||||
MavenConstants.TYPE_JAR,
|
||||
null);
|
||||
Artifact artifact = embedder.resolve(id, MavenConstants.TYPE_JAR, null, mavenProject.getRemoteRepositories());
|
||||
artifact.setScope(Artifact.SCOPE_COMPILE);
|
||||
embedder.resolve(artifact, mavenProject.getRemoteRepositories());
|
||||
return new MavenArtifact(artifact, mavenProject.getLocalRepository());
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -25,8 +25,8 @@ public class MavenConstants {
|
||||
public static final String TYPE_JAR = "jar";
|
||||
public static final String TYPE_WAR = "war";
|
||||
|
||||
public static final String JAVADOC_CLASSIFIER = "javadoc";
|
||||
public static final String SOURCES_CLASSIFIER = "sources";
|
||||
public static final String CLASSIFIER_JAVADOC = "javadoc";
|
||||
public static final String CLASSIFIER_SOURCES = "sources";
|
||||
|
||||
public static final String SCOPE_COMPILE = "compile";
|
||||
public static final String SCOPE_PROVIDEED = "provided";
|
||||
|
||||
@@ -14,7 +14,6 @@ maven.downloading.plugins=Downloading Maven plugins
|
||||
maven.downloading.pom.plugins=Downloading plugins for {0}
|
||||
maven.downloading=Downloading Maven sources and javadocs
|
||||
maven.downloading.finished=Finished downloading artifacts
|
||||
maven.downloading.artifact=Downloading {0}
|
||||
maven.transfer.progress={0}/{1}K [{2}] {3}
|
||||
maven.transfer.start=Checking [{0}] {1}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user