use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-community by JetBrains.
the class MavenModuleImporter method configDependencies.
private void configDependencies() {
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myModule.getProject().isDisposed())
return;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myModule.getProject()).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
String dependencyType = artifact.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !myMavenProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
DependencyScope scope = selectScope(artifact.getScope());
MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
if (depProject != null) {
if (depProject == myMavenProject)
continue;
String moduleName = myMavenProjectToModuleName.get(depProject);
if (moduleName == null || myMavenTree.isIgnored(depProject)) {
MavenArtifact projectsArtifactInRepository = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(projectsArtifactInRepository, scope, myModifiableModelsProvider, myMavenProject);
} else {
boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(dependencyType) || "tests".equals(artifact.getClassifier());
myRootModelAdapter.addModuleDependency(moduleName, scope, isTestJar);
Element buildHelperCfg = depProject.getPluginGoalConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
if (buildHelperCfg != null) {
addAttachArtifactDependency(buildHelperCfg, scope, depProject, artifact);
}
if (IMPORTED_CLASSIFIERS.contains(artifact.getClassifier()) && !isTestJar && !"system".equals(artifact.getScope()) && !"false".equals(System.getProperty("idea.maven.classifier.dep"))) {
MavenArtifact a = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(a, scope, myModifiableModelsProvider, myMavenProject);
}
}
} else if ("system".equals(artifact.getScope())) {
myRootModelAdapter.addSystemDependency(artifact, scope);
} else {
myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
}
}
configSurefirePlugin();
}
use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-community by JetBrains.
the class MavenProjectImporter method scheduleRefreshResolvedArtifacts.
private void scheduleRefreshResolvedArtifacts(List<MavenProjectsProcessorTask> postTasks) {
// We have to refresh all the resolved artifacts manually in order to
// update all the VirtualFilePointers. It is not enough to call
// VirtualFileManager.refresh() since the newly created files will be only
// picked by FS when FileWatcher finishes its work. And in the case of import
// it doesn't finish in time.
// I couldn't manage to write a test for this since behaviour of VirtualFileManager
// and FileWatcher differs from real-life execution.
List<MavenArtifact> artifacts = new ArrayList<>();
for (MavenProject each : myProjectsToImportWithChanges.keySet()) {
artifacts.addAll(each.getDependencies());
}
final Set<File> files = new THashSet<>();
for (MavenArtifact each : artifacts) {
if (each.isResolved())
files.add(each.getFile());
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
doRefreshFiles(files);
} else {
postTasks.add(new MavenProjectsProcessorTask() {
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator) throws MavenProcessCanceledException {
indicator.setText("Refreshing files...");
doRefreshFiles(files);
}
});
}
}
use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-community by JetBrains.
the class MavenArtifactIndex method findArtifacts.
@NotNull
public List<MavenArtifact> findArtifacts(@Nullable String groupId, @Nullable String artifactId, @Nullable String version) {
Map<String, List<MavenArtifact>> groupMap = myData.get(groupId);
if (groupMap == null)
return Collections.emptyList();
List<MavenArtifact> artifacts = groupMap.get(artifactId);
if (artifacts == null)
return Collections.emptyList();
List<MavenArtifact> res = new SmartList<>();
for (MavenArtifact artifact : artifacts) {
if (Comparing.equal(version, artifact.getVersion())) {
res.add(artifact);
}
}
return res;
}
use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-community by JetBrains.
the class AppEngineFacetImporter method resolve.
@Override
public void resolve(Project project, MavenProject mavenProject, NativeMavenProjectHolder nativeMavenProject, MavenEmbedderWrapper embedder, ResolveContext context) throws MavenProcessCanceledException {
String version = getVersion(mavenProject);
if (version != null) {
List<MavenRemoteRepository> repos = mavenProject.getRemoteRepositories();
MavenArtifactInfo artifactInfo = new MavenArtifactInfo("com.google.appengine", "appengine-java-sdk", version, "zip", null);
MavenArtifact artifact = embedder.resolve(artifactInfo, repos);
File file = artifact.getFile();
File unpackedSdkPath = new File(file.getParentFile(), "appengine-java-sdk");
if (file.exists() && !AppEngineSdkUtil.checkPath(FileUtil.toSystemIndependentName(unpackedSdkPath.getAbsolutePath())).isOk()) {
try {
ZipUtil.extract(file, unpackedSdkPath, null, false);
} catch (IOException e) {
MavenLog.LOG.warn("cannot unpack AppEngine SDK", e);
}
}
}
}
use of org.jetbrains.idea.maven.model.MavenArtifact in project intellij-plugins by JetBrains.
the class DependencyEmbedder method processHeaders.
public void processHeaders(Analyzer analyzer) throws DependencyEmbedderException {
StringBuilder includeResource = new StringBuilder();
StringBuilder bundleClassPath = new StringBuilder();
StringBuilder embeddedArtifacts = new StringBuilder();
myInlinePaths.clear();
myEmbeddedArtifacts.clear();
String embedDependencyHeader = analyzer.getProperty(EMBED_DEPENDENCY);
if (StringUtil.isNotEmpty(embedDependencyHeader)) {
myEmbedDirectory = analyzer.getProperty(EMBED_DIRECTORY);
myEmbedStripGroup = analyzer.getProperty(EMBED_STRIP_GROUP, "true");
myEmbedStripVersion = analyzer.getProperty(EMBED_STRIP_VERSION);
processInstructions(embedDependencyHeader);
for (String inlinePath : myInlinePaths) {
inlineDependency(inlinePath, includeResource);
}
for (MavenArtifact embeddedArtifact : myEmbeddedArtifacts) {
embedDependency(embeddedArtifact, includeResource, bundleClassPath, embeddedArtifacts);
}
}
if (analyzer.getProperty(Constants.WAB) == null && bundleClassPath.length() > 0) {
// set explicit default before merging dependency classpath
if (analyzer.getProperty(Constants.BUNDLE_CLASSPATH) == null) {
analyzer.setProperty(Constants.BUNDLE_CLASSPATH, ".");
}
}
appendDependencies(analyzer, Constants.INCLUDE_RESOURCE, includeResource.toString());
appendDependencies(analyzer, Constants.BUNDLE_CLASSPATH, bundleClassPath.toString());
appendDependencies(analyzer, EMBEDDED_ARTIFACTS, embeddedArtifacts.toString());
}
Aggregations