├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── jsLibraryMappings.xml ├── misc.xml ├── modules.xml ├── scopes │ └── scope_settings.xml ├── uiDesigner.xml └── vcs.xml ├── GradleDependencySupport.iml ├── LICENSE ├── META-INF └── plugin.xml ├── README.md └── src └── main └── java ├── org └── ligi │ └── gradecoba │ ├── AndroidArtifact.java │ ├── Artifact.java │ ├── ArtifactProvider.java │ └── GoogleArtifact.java └── siosio ├── GradleDependenciesCompletionContributor.java └── MavenFindAction.java /.idea/.name: -------------------------------------------------------------------------------- 1 | GradleDependencySupport -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 702 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 21 | 22 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 457 | 458 | 459 | 460 | 476 | 477 | 480 | 481 | 483 | 484 | 485 | 486 | 487 | 497 | 498 | 501 | 502 | 504 | 505 | 538 | 539 | 554 | 712 | 726 | 727 | 728 | 729 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GradleDependencySupport.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 siosio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /META-INF/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | GradleDependenciesHelper 3 | Gradle Dependencies Helper 4 | 1.4 5 | siosio 6 | org.jetbrains.plugins.gradle 7 | org.intellij.groovy 8 | 9 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Gradle Maven Dependencies AutoCompletion Plugin 2 | =============================================== 3 | 4 | IntelliJ AutoCompletion plugin for maven gradle dependencies 5 | 6 | Installation 7 | ============ 8 | 9 | #1 Download the plugin from here: https://github.com/ligi/GradleDependenciesHelperPlugin/releases 10 | 11 | #2 go to settings->plugins->install from disk and choose the jar you just downloaded 12 | 13 | Usage 14 | ===== 15 | 16 | in your build.gradle type 17 | 18 | compile ' and then the key you configured for completion - minimum 5 chars ( might change this to 3 or 4 in the future ) 19 | 20 | 21 | 22 | Background 23 | ========== 24 | 25 | forked to make it more useful for Android-Studio. 26 | 27 | forked from: 28 | https://github.com/siosio/GradleDependenciesHelperPlugin 29 | 30 | 31 | orig README 32 | =========== 33 | 34 | Gradleのdependencies内で、mavenからライブラリ検索して補完出来るプラグイン 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/org/ligi/gradecoba/AndroidArtifact.java: -------------------------------------------------------------------------------- 1 | package org.ligi.gradecoba; 2 | 3 | public class AndroidArtifact extends Artifact { 4 | 5 | public AndroidArtifact(String artifact, String version,String repository, boolean aar) { 6 | super("com.android.support", artifact, version, repository, aar); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/ligi/gradecoba/Artifact.java: -------------------------------------------------------------------------------- 1 | package org.ligi.gradecoba; 2 | 3 | public class Artifact { 4 | 5 | private final String group; 6 | private final String name; 7 | private final String version; 8 | private final String repository; 9 | private final boolean servesAAR; 10 | 11 | public Artifact(String group,String name,String version,String repository,boolean aar) { 12 | this.version = version; 13 | this.name = name; 14 | this.repository = repository; 15 | this.group = group; 16 | this.servesAAR = aar; 17 | } 18 | 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | public String getGradleDependencyString() { 24 | String res=group+":"+name+":"+version; 25 | if (servesAAR) { 26 | res+="@AAR"; 27 | } 28 | return res; 29 | } 30 | 31 | public String getRepo() { 32 | return repository; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/ligi/gradecoba/ArtifactProvider.java: -------------------------------------------------------------------------------- 1 | package org.ligi.gradecoba; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ArtifactProvider { 7 | private List artifacts; 8 | 9 | public List getArtifacts() { 10 | if (artifacts==null) { 11 | artifacts = new ArrayList(); 12 | artifacts.add(new GoogleArtifact("play-services","4.4.52","google",false)); 13 | artifacts.add(new AndroidArtifact("gridlayout-v7","19.1.0","android-support",false)); 14 | artifacts.add(new AndroidArtifact("support-v13","19.1.0","android-support",false)); 15 | artifacts.add(new AndroidArtifact("mediarouter-v7","19.1.0","android-support",false)); 16 | artifacts.add(new AndroidArtifact("appcompat-v7","19.1.0","android-support",false)); 17 | artifacts.add(new AndroidArtifact("support-v4","19.1.0","android-support",false)); 18 | } 19 | 20 | return artifacts; 21 | } 22 | 23 | 24 | public List searchArtifacts(String query) { 25 | List res = new ArrayList(); 26 | 27 | if (query.startsWith("gms")) { 28 | query="play"; 29 | } 30 | 31 | for (Artifact artifact:getArtifacts()) { 32 | if (artifact.getName().contains(query)) { 33 | res.add(artifact); 34 | } 35 | } 36 | return res; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/main/java/org/ligi/gradecoba/GoogleArtifact.java: -------------------------------------------------------------------------------- 1 | package org.ligi.gradecoba; 2 | 3 | public class GoogleArtifact extends Artifact{ 4 | 5 | public GoogleArtifact(String artifact, String version,String repository, boolean aar) { 6 | super("com.google.android.gms", artifact, version, repository, aar); 7 | } 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/siosio/GradleDependenciesCompletionContributor.java: -------------------------------------------------------------------------------- 1 | package siosio; 2 | 3 | import java.util.List; 4 | 5 | import com.intellij.codeInsight.completion.CompletionContributor; 6 | import com.intellij.codeInsight.completion.CompletionParameters; 7 | import com.intellij.codeInsight.completion.CompletionProvider; 8 | import com.intellij.codeInsight.completion.CompletionResultSet; 9 | import com.intellij.codeInsight.completion.CompletionType; 10 | import com.intellij.codeInsight.lookup.LookupElement; 11 | import com.intellij.openapi.util.text.StringUtil; 12 | import com.intellij.psi.PsiElement; 13 | import com.intellij.util.ProcessingContext; 14 | import org.jetbrains.annotations.NotNull; 15 | import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement; 16 | import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral; 17 | import org.ligi.gradecoba.Artifact; 18 | import org.ligi.gradecoba.ArtifactProvider; 19 | 20 | import static com.intellij.patterns.PlatformPatterns.psiElement; 21 | 22 | public class GradleDependenciesCompletionContributor extends CompletionContributor { 23 | 24 | public GradleDependenciesCompletionContributor() { 25 | extend(CompletionType.BASIC, 26 | psiElement(PsiElement.class) 27 | .withSuperParent(3, psiElement(GrApplicationStatement.class)) 28 | .withParent(GrLiteral.class), 29 | new CompletionParametersCompletionProvider()); 30 | } 31 | 32 | private static class CompletionParametersCompletionProvider extends CompletionProvider { 33 | 34 | @Override 35 | protected void addCompletions( 36 | @NotNull CompletionParameters parameters, 37 | ProcessingContext context, 38 | @NotNull CompletionResultSet set) { 39 | 40 | if (!parameters.getOriginalFile().getName().endsWith(".gradle")) { 41 | return; 42 | } 43 | 44 | PsiElement position = parameters.getOriginalPosition(); 45 | if (position == null) { 46 | return; 47 | } 48 | String text = trimQuote(position.getText()); 49 | if (StringUtil.isEmpty(text) || text.length() < 3) { 50 | return; 51 | } 52 | 53 | List result = new MavenFindAction().find(text); 54 | 55 | if (parameters.getOriginalFile().getText().contains("android")) { 56 | for (Artifact artifact: new ArtifactProvider().searchArtifacts(text)) { 57 | result.add(0,artifact.getGradleDependencyString()); 58 | } 59 | } 60 | 61 | for (final String id : result) { 62 | set.addElement(new LookupElement() { 63 | @NotNull 64 | @Override 65 | public String getLookupString() { 66 | return id; 67 | } 68 | }); 69 | } 70 | set.stopHere(); 71 | } 72 | 73 | private String trimQuote(String text) { 74 | if (text.startsWith("'") || text.startsWith("\"")) { 75 | text = text.substring(1); 76 | } 77 | if (text.endsWith("'") || text.endsWith("\"")) { 78 | text = text.substring(0, text.length() - 1); 79 | } 80 | return text; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/siosio/MavenFindAction.java: -------------------------------------------------------------------------------- 1 | package siosio; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import java.util.regex.Matcher; 12 | import java.util.regex.Pattern; 13 | 14 | public class MavenFindAction { 15 | 16 | private static final Pattern PATTERN = Pattern.compile( 17 | "\\{\"id\":\"([^\"]+)\"[^\\}]+\"latestVersion\":\"([^\"]+)\""); 18 | 19 | public List find(String text) { 20 | List result = new ArrayList(); 21 | try { 22 | HttpURLConnection connection = getConnection( 23 | "http://search.maven.org/solrsearch/select?q="+text+"&rows=20&wt=json"); 24 | //"http://search.maven.org/solrsearch/select?q=a:" + text + "+OR+a:" + text + "*&rows=20&wt=json"); 25 | 26 | InputStream stream = getResponse(connection); 27 | BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); 28 | 29 | String line = null; 30 | while ((line = reader.readLine()) != null) { 31 | Matcher matcher = PATTERN.matcher(line); 32 | while (matcher.find()) { 33 | result.add(matcher.group(1) + ':' + matcher.group(2)); 34 | } 35 | } 36 | } catch (IOException ignore) { 37 | return result; 38 | } 39 | return result; 40 | } 41 | 42 | private static HttpURLConnection getConnection(final String spec) throws IOException { 43 | URL url = new URL(spec); 44 | return (HttpURLConnection) url.openConnection(); 45 | } 46 | 47 | private static InputStream getResponse(HttpURLConnection connection) throws IOException { 48 | if (connection.getResponseCode() != 200) { 49 | throw new IOException("response is abnormal end."); 50 | } 51 | return connection.getInputStream(); 52 | } 53 | } 54 | 55 | --------------------------------------------------------------------------------