From c3e2e41b5694fa762020afba7ad0b66704ed06bf Mon Sep 17 00:00:00 2001 From: Nikolay Mikhaylov Date: Fri, 3 Jun 2016 15:22:43 +0300 Subject: [PATCH] refactoring arquillian containers --- .../utils/library/RepositoryLibraryBean.java | 35 +++++++++++++++++++ .../library/RepositoryLibraryDescription.java | 19 ++++------ .../src/main/resources/META-INF/plugin.xml | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java new file mode 100644 index 000000000000..61630b393141 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryBean.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.maven.utils.library; + +import com.intellij.openapi.extensions.AbstractExtensionPointBean; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.util.xmlb.annotations.Attribute; +import com.intellij.util.xmlb.annotations.Tag; + +public class RepositoryLibraryBean extends AbstractExtensionPointBean { + protected static final ExtensionPointName EP_NAME + = ExtensionPointName.create("org.jetbrains.idea.maven.mavenCoordinates"); + + @Attribute("name") + public String name; + + @Tag("groupId") + public String groupId; + + @Tag("artifactId") + public String artifactId; +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java index 72a639575554..5d3fcfcfebe9 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryLibraryDescription.java @@ -15,7 +15,6 @@ */ package org.jetbrains.idea.maven.utils.library; -import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.roots.DependencyScope; import com.intellij.util.containers.HashMap; import icons.MavenIcons; @@ -29,8 +28,6 @@ import java.util.List; import java.util.Map; public class RepositoryLibraryDescription { - protected static final ExtensionPointName EP_NAME - = ExtensionPointName.create("org.jetbrains.idea.maven.repositoryLibrary"); protected static final MavenRepositoryInfo mavenCentralRepository = new MavenRepositoryInfo( "central", "Maven Central repository", @@ -52,20 +49,16 @@ public class RepositoryLibraryDescription { this.libraryName = libraryName; } - public static C ofClass(Class clazz) { - return EP_NAME.findExtension(clazz); - } - @NotNull public static synchronized RepositoryLibraryDescription findDescription(@NotNull final String groupId, @NotNull final String artifactId) { if (registeredLibraries == null) { registeredLibraries = new HashMap(); - for (RepositoryLibraryDescription description : EP_NAME.getExtensions()) { - String id = description.getGroupId() + ":" + description.getArtifactId(); - RepositoryLibraryDescription existDescription = registeredLibraries.get(id); - if (existDescription == null || existDescription.getWeight() >= description.getWeight()) { - registeredLibraries.put(id, description); - } + for (RepositoryLibraryBean bean : RepositoryLibraryBean.EP_NAME.getExtensions()) { + String id = bean.groupId + ":" + bean.artifactId; + registeredLibraries.put(id, new RepositoryLibraryDescription( + bean.groupId, + bean.artifactId, + bean.name)); } } final String id = groupId + ":" + artifactId; diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index 15e0a5ce5703..1390b0efbad7 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -28,7 +28,7 @@ - + com.intellij.properties