[maven] IDEA-91662 doesn't take into account mirror repositories as Indexed Maven...
[idea/community.git] / plugins / maven / src / test / java / org / jetbrains / idea / maven / project / importing / MavenProjectTest.java
1 // Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
2
3 package org.jetbrains.idea.maven.project.importing;
4
5 import com.intellij.compiler.CompilerConfiguration;
6 import com.intellij.compiler.CompilerConfigurationImpl;
7 import com.intellij.openapi.module.LanguageLevelUtil;
8 import com.intellij.openapi.util.io.FileUtil;
9 import com.intellij.openapi.util.text.StringUtil;
10 import com.intellij.openapi.vfs.VirtualFile;
11 import com.intellij.pom.java.LanguageLevel;
12 import org.jetbrains.idea.maven.MavenMultiVersionImportingTestCase;
13 import org.jetbrains.idea.maven.model.MavenArtifactNode;
14 import org.jetbrains.idea.maven.model.MavenPlugin;
15 import org.jetbrains.idea.maven.model.MavenRemoteRepository;
16 import org.jetbrains.idea.maven.project.MavenProject;
17 import org.jetbrains.idea.maven.project.MavenProjectsManager;
18 import org.jetbrains.idea.maven.utils.MavenJDOMUtil;
19 import org.junit.Assert;
20 import org.junit.Test;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.util.*;
25 import java.util.stream.Collectors;
26
27 public class MavenProjectTest extends MavenMultiVersionImportingTestCase {
28   @Test 
29   public void testCollectingPlugins() {
30     importProject("<groupId>test</groupId>" +
31                   "<artifactId>project</artifactId>" +
32                   "<version>1</version>" +
33                   "<build>" +
34                   "  <plugins>" +
35                   "    <plugin>" +
36                   "      <groupId>group1</groupId>" +
37                   "      <artifactId>id1</artifactId>" +
38                   "      <version>1</version>" +
39                   "    </plugin>" +
40                   "    <plugin>" +
41                   "      <groupId>group1</groupId>" +
42                   "      <artifactId>id2</artifactId>" +
43                   "    </plugin>" +
44                   "    <plugin>" +
45                   "      <groupId>group2</groupId>" +
46                   "      <artifactId>id1</artifactId>" +
47                   "    </plugin>" +
48                   "  </plugins>" +
49                   "</build>");
50
51     assertModules("project");
52
53     assertDeclaredPlugins(p("group1", "id1"), p("group1", "id2"), p("group2", "id1"));
54   }
55
56   @Test 
57   public void testPluginsContainDefaultPlugins() {
58     importProject("<groupId>test</groupId>" +
59                   "<artifactId>project</artifactId>" +
60                   "<version>1</version>" +
61                   "<build>" +
62                   "  <plugins>" +
63                   "    <plugin>" +
64                   "      <groupId>group1</groupId>" +
65                   "      <artifactId>id1</artifactId>" +
66                   "      <version>1</version>" +
67                   "    </plugin>" +
68                   "  </plugins>" +
69                   "</build>");
70
71     assertModules("project");
72
73     assertContain(p(getMavenProject().getPlugins()), p("group1", "id1"), p("org.apache.maven.plugins", "maven-compiler-plugin"));
74   }
75
76   @Test 
77   public void testDefaultPluginsAsDeclared() {
78     importProject("<groupId>test</groupId>" +
79                   "<artifactId>project</artifactId>" +
80                   "<version>1</version>" +
81                   "<build>" +
82                   "  <plugins>" +
83                   "    <plugin>" +
84                   "      <groupId>org.apache.maven.plugins</groupId>" +
85                   "      <artifactId>maven-compiler-plugin</artifactId>" +
86                   "    </plugin>" +
87                   "  </plugins>" +
88                   "</build>");
89
90     assertModules("project");
91
92     assertDeclaredPlugins(p("org.apache.maven.plugins", "maven-compiler-plugin"));
93   }
94
95   @Test 
96   public void testDoNotDuplicatePluginsFromBuildAndManagement() {
97     importProject("<groupId>test</groupId>" +
98                   "<artifactId>project</artifactId>" +
99                   "<version>1</version>" +
100                   "<build>" +
101                   "  <plugins>" +
102                   "    <plugin>" +
103                   "      <groupId>org.apache.maven.plugins</groupId>" +
104                   "      <artifactId>maven-compiler-plugin</artifactId>" +
105                   "    </plugin>" +
106                   "  </plugins>" +
107                   "  <pluginManagement>" +
108                   "    <plugins>" +
109                   "      <plugin>" +
110                   "        <groupId>org.apache.maven.plugins</groupId>" +
111                   "        <artifactId>maven-compiler-plugin</artifactId>" +
112                   "      </plugin>" +
113                   "    </plugins>" +
114                   "  </pluginManagement>" +
115                   "</build>");
116
117     assertModules("project");
118
119     assertDeclaredPlugins(p("org.apache.maven.plugins", "maven-compiler-plugin"));
120   }
121
122   @Test 
123   public void testCollectingPluginsFromProfilesAlso() {
124     importProject("<groupId>test</groupId>" +
125                   "<artifactId>project</artifactId>" +
126                   "<version>1</version>" +
127
128                   "<build>" +
129                   "  <plugins>" +
130                   "    <plugin>" +
131                   "      <groupId>group</groupId>" +
132                   "      <artifactId>id</artifactId>" +
133                   "      <version>1</version>" +
134                   "    </plugin>" +
135                   "  </plugins>" +
136                   "</build>" +
137
138                   "<profiles>" +
139                   "  <profile>" +
140                   "    <id>profile1</id>" +
141                   "    <build>" +
142                   "      <plugins>" +
143                   "        <plugin>" +
144                   "          <groupId>group1</groupId>" +
145                   "          <artifactId>id1</artifactId>" +
146                   "        </plugin>" +
147                   "      </plugins>" +
148                   "    </build>" +
149                   "  </profile>" +
150                   "  <profile>" +
151                   "    <id>profile2</id>" +
152                   "    <build>" +
153                   "      <plugins>" +
154                   "        <plugin>" +
155                   "          <groupId>group2</groupId>" +
156                   "          <artifactId>id2</artifactId>" +
157                   "        </plugin>" +
158                   "      </plugins>" +
159                   "    </build>" +
160                   "  </profile>" +
161                   "</profiles>");
162
163     assertModules("project");
164
165     assertDeclaredPlugins(p("group", "id"));
166
167     importProjectWithProfiles("profile1");
168     assertDeclaredPlugins(p("group", "id"), p("group1", "id1"));
169
170     importProjectWithProfiles("profile2");
171     assertDeclaredPlugins(p("group", "id"), p("group2", "id2"));
172
173     importProjectWithProfiles("profile1", "profile2");
174     assertDeclaredPlugins(p("group", "id"), p("group1", "id1"), p("group2", "id2"));
175   }
176
177   @Test
178   public void testFindingPlugin() {
179     importProject("<groupId>test</groupId>" +
180                   "<artifactId>project</artifactId>" +
181                   "<version>1</version>" +
182
183                   "<build>" +
184                   "  <plugins>" +
185                   "    <plugin>" +
186                   "      <groupId>group</groupId>" +
187                   "      <artifactId>id</artifactId>" +
188                   "      <version>1</version>" +
189                   "    </plugin>" +
190                   "  </plugins>" +
191                   "</build>" +
192
193                   "<profiles>" +
194                   "  <profile>" +
195                   "    <id>profile1</id>" +
196                   "    <build>" +
197                   "      <plugins>" +
198                   "        <plugin>" +
199                   "          <groupId>group1</groupId>" +
200                   "          <artifactId>id1</artifactId>" +
201                   "        </plugin>" +
202                   "      </plugins>" +
203                   "    </build>" +
204                   "  </profile>" +
205                   "  <profile>" +
206                   "    <id>profile2</id>" +
207                   "    <build>" +
208                   "      <plugins>" +
209                   "        <plugin>" +
210                   "          <groupId>group2</groupId>" +
211                   "          <artifactId>id2</artifactId>" +
212                   "        </plugin>" +
213                   "      </plugins>" +
214                   "    </build>" +
215                   "  </profile>" +
216                   "</profiles>");
217
218     assertModules("project");
219
220     assertEquals(p("group", "id"), p(findPlugin("group", "id")));
221     assertNull(findPlugin("group1", "id1"));
222
223     importProjectWithProfiles("profile1");
224     assertEquals(p("group1", "id1"), p(findPlugin("group1", "id1")));
225     assertNull(findPlugin("group2", "id2"));
226   }
227
228   @Test 
229   public void testFindingDefaultPlugin() {
230     importProject("<groupId>test</groupId>" +
231                   "<artifactId>project</artifactId>" +
232                   "<version>1</version>" +
233
234                   "<build>" +
235                   "  <plugins>" +
236                   "    <plugin>" +
237                   "      <groupId>group</groupId>" +
238                   "      <artifactId>id</artifactId>" +
239                   "      <version>1</version>" +
240                   "    </plugin>" +
241                   "  </plugins>" +
242                   "</build>");
243
244     assertModules("project");
245
246     assertNotNull(findPlugin("group", "id"));
247     assertNotNull(findPlugin("org.apache.maven.plugins", "maven-compiler-plugin"));
248   }
249
250   @Test 
251   public void testFindingMavenGroupPluginWithDefaultPluginGroup() {
252     importProject("<groupId>test</groupId>" +
253                   "<artifactId>project</artifactId>" +
254                   "<version>1</version>" +
255
256                   "<build>" +
257                   "  <plugins>" +
258                   "    <plugin>" +
259                   "      <artifactId>some.plugin.id</artifactId>" +
260                   "    </plugin>" +
261                   "  </plugins>" +
262                   "</build>");
263     assertModules("project");
264
265     assertEquals(p("org.apache.maven.plugins", "some.plugin.id"),
266                  p(findPlugin("org.apache.maven.plugins", "some.plugin.id")));
267     assertNull(findPlugin("some.other.group.id", "some.plugin.id"));
268   }
269
270   @Test 
271   public void testPluginConfiguration() {
272     importProject("<groupId>test</groupId>" +
273                   "<artifactId>project</artifactId>" +
274                   "<version>1</version>" +
275
276                   "<build>" +
277                   "  <plugins>" +
278                   "    <plugin>" +
279                   "      <groupId>group</groupId>" +
280                   "      <artifactId>id1</artifactId>" +
281                   "      <version>1</version>" +
282                   "    </plugin>" +
283                   "    <plugin>" +
284                   "      <groupId>group</groupId>" +
285                   "      <artifactId>id2</artifactId>" +
286                   "      <version>1</version>" +
287                   "      <configuration>" +
288                   "      </configuration>" +
289                   "    </plugin>" +
290                   "    <plugin>" +
291                   "      <groupId>group</groupId>" +
292                   "      <artifactId>id3</artifactId>" +
293                   "      <version>1</version>" +
294                   "      <configuration>" +
295                   "        <one>" +
296                   "          <two>foo</two>" +
297                   "        </one>" +
298                   "      </configuration>" +
299                   "    </plugin>" +
300                   "  </plugins>" +
301                   "</build>");
302
303     assertNull(findPluginConfig("group", "id1", "one.two"));
304     assertNull(findPluginConfig("group", "id2", "one.two"));
305     assertEquals("foo", findPluginConfig("group", "id3", "one.two"));
306     assertNull(findPluginConfig("group", "id3", "one.two.three"));
307   }
308
309   @Test 
310   public void testPluginGoalConfiguration() {
311     importProject("<groupId>test</groupId>" +
312                   "<artifactId>project</artifactId>" +
313                   "<version>1</version>" +
314
315                   "<build>" +
316                   "  <plugins>" +
317                   "    <plugin>" +
318                   "      <groupId>group</groupId>" +
319                   "      <artifactId>id</artifactId>" +
320                   "      <version>1</version>" +
321                   "      <executions>" +
322                   "        <execution>" +
323                   "          <id>a</id>" +
324                   "          <goals>" +
325                   "            <goal>compile</goal>" +
326                   "          </goals>" +
327                   "          <configuration>" +
328                   "            <one>" +
329                   "              <two>a</two>" +
330                   "            </one>" +
331                   "          </configuration>" +
332                   "        </execution>" +
333                   "        <execution>" +
334                   "          <id>b</id>" +
335                   "          <goals>" +
336                   "            <goal>testCompile</goal>" +
337                   "          </goals>" +
338                   "          <configuration>" +
339                   "            <one>" +
340                   "              <two>b</two>" +
341                   "            </one>" +
342                   "          </configuration>" +
343                   "        </execution>" +
344                   "      </executions>" +
345                   "    </plugin>" +
346                   "  </plugins>" +
347                   "</build>");
348
349     assertNull(findPluginGoalConfig("group", "id", "package", "one.two"));
350     assertEquals("a", findPluginGoalConfig("group", "id", "compile", "one.two"));
351     assertEquals("b", findPluginGoalConfig("group", "id", "testCompile", "one.two"));
352   }
353
354   @Test 
355   public void testPluginConfigurationHasResolvedVariables() {
356     importProject("<groupId>test</groupId>" +
357                   "<artifactId>project</artifactId>" +
358                   "<version>1</version>" +
359
360                   "<properties>" +
361                   "  <some.path>somePath</some.path>" +
362                   "</properties>" +
363
364                   "<build>" +
365                   "  <plugins>" +
366                   "    <plugin>" +
367                   "      <groupId>group</groupId>" +
368                   "      <artifactId>id</artifactId>" +
369                   "      <version>1</version>" +
370                   "      <configuration>" +
371                   "        <one>${some.path}</one>" +
372                   "      </configuration>" +
373                   "    </plugin>" +
374                   "  </plugins>" +
375                   "</build>");
376
377     assertEquals("somePath", findPluginConfig("group", "id", "one"));
378   }
379
380   @Test 
381   public void testPluginConfigurationWithStandardVariable() {
382     importProject("<groupId>test</groupId>" +
383                   "<artifactId>project</artifactId>" +
384                   "<version>1</version>" +
385
386                   "<build>" +
387                   "  <plugins>" +
388                   "    <plugin>" +
389                   "      <groupId>group</groupId>" +
390                   "      <artifactId>id</artifactId>" +
391                   "      <version>1</version>" +
392                   "      <configuration>" +
393                   "        <one>${project.build.directory}</one>" +
394                   "      </configuration>" +
395                   "    </plugin>" +
396                   "  </plugins>" +
397                   "</build>");
398
399     assertEquals(getProjectPath() + "/target",
400                  FileUtil.toSystemIndependentName(findPluginConfig("group", "id", "one")));
401   }
402
403   @Test 
404   public void testPluginConfigurationWithColons() {
405     importProject("<groupId>test</groupId>" +
406                   "<artifactId>project</artifactId>" +
407                   "<version>1</version>" +
408                   "<build>" +
409                   "  <plugins>" +
410                   "    <plugin>" +
411                   "      <groupId>group</groupId>" +
412                   "      <artifactId>id</artifactId>" +
413                   "      <version>1</version>" +
414                   "      <configuration>" +
415                   "        <two:three>xxx</two:three>" +
416                   "      </configuration>" +
417                   "    </plugin>" +
418                   "  </plugins>" +
419                   "</build>");
420
421     assertNull(findPluginConfig("group", "id", "two:three"));
422   }
423
424   @Test 
425   public void testMergingPluginConfigurationFromBuildAndProfiles() {
426     createProjectPom("<groupId>test</groupId>" +
427                      "<artifactId>project</artifactId>" +
428                      "<version>1</version>" +
429
430                      "<profiles>" +
431                      "  <profile>" +
432                      "    <id>one</id>" +
433                      "    <build>" +
434                      "      <plugins>" +
435                      "        <plugin>" +
436                      "          <groupId>org.apache.maven.plugins</groupId>" +
437                      "          <artifactId>maven-compiler-plugin</artifactId>" +
438                      "          <configuration>" +
439                      "            <target>1.4</target>" +
440                      "          </configuration>" +
441                      "        </plugin>" +
442                      "      </plugins>" +
443                      "    </build>" +
444                      "  </profile>" +
445                      "  <profile>" +
446                      "    <id>two</id>" +
447                      "    <build>" +
448                      "      <plugins>" +
449                      "        <plugin>" +
450                      "          <groupId>org.apache.maven.plugins</groupId>" +
451                      "          <artifactId>maven-compiler-plugin</artifactId>" +
452                      "          <configuration>" +
453                      "            <source>1.4</source>" +
454                      "          </configuration>" +
455                      "        </plugin>" +
456                      "      </plugins>" +
457                      "    </build>" +
458                      "  </profile>" +
459                      "</profiles>" +
460
461                      "<build>" +
462                      "  <plugins>" +
463                      "    <plugin>" +
464                      "      <groupId>org.apache.maven.plugins</groupId>" +
465                      "      <artifactId>maven-compiler-plugin</artifactId>" +
466                      "      <configuration>" +
467                      "        <debug>true</debug>" +
468                      "      </configuration>" +
469                      "    </plugin>" +
470                      "  </plugins>" +
471                      "</build>");
472     importProjectWithProfiles("one", "two");
473
474     MavenPlugin plugin = findPlugin("org.apache.maven.plugins", "maven-compiler-plugin");
475     assertEquals("1.4", plugin.getConfigurationElement().getChildText("source"));
476     assertEquals("1.4", plugin.getConfigurationElement().getChildText("target"));
477     assertEquals("true", plugin.getConfigurationElement().getChildText("debug"));
478   }
479
480   @Test 
481   public void testCompilerPluginConfigurationFromProperties() {
482     createProjectPom("<groupId>test</groupId>" +
483                      "<artifactId>project</artifactId>" +
484                      "<version>1</version>" +
485
486                      "<properties>\n" +
487                      "        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" +
488                      "        <maven.compiler.source>1.7</maven.compiler.source>\n" +
489                      "        <maven.compiler.target>1.7</maven.compiler.target>\n" +
490                      "</properties>");
491
492     importProject();
493
494     assertEquals("1.7", getMavenProject().getSourceLevel());
495     assertEquals("1.7", getMavenProject().getTargetLevel());
496   }
497
498   @Test 
499   public void testCompilerPluginConfigurationFromPropertiesOverride() {
500     createProjectPom("<groupId>test</groupId>" +
501                      "<artifactId>project</artifactId>" +
502                      "<version>1</version>" +
503
504                      "<properties>\n" +
505                      "        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" +
506                      "        <maven.compiler.source>1.7</maven.compiler.source>\n" +
507                      "        <maven.compiler.target>1.7</maven.compiler.target>\n" +
508                      "</properties>" +
509
510                      "<build>" +
511                      "  <plugins>" +
512                      "    <plugin>" +
513                      "      <groupId>org.apache.maven.plugins</groupId>" +
514                      "      <artifactId>maven-compiler-plugin</artifactId>" +
515                      "      <configuration>" +
516                      "        <target>1.4</target>" +
517                      "        <source>1.4</source>" +
518                      "      </configuration>" +
519                      "    </plugin>" +
520                      "  </plugins>" +
521                      "</build>");
522
523     importProject();
524
525     assertEquals("1.4", getMavenProject().getSourceLevel());
526     assertEquals("1.4", getMavenProject().getTargetLevel());
527   }
528
529   @Test 
530   public void testCompilerPluginConfigurationRelease() {
531     createProjectPom("<groupId>test</groupId>" +
532                      "<artifactId>project</artifactId>" +
533                      "<version>1</version>" +
534
535                      "<build>" +
536                      "  <plugins>" +
537                      "    <plugin>" +
538                      "      <groupId>org.apache.maven.plugins</groupId>" +
539                      "      <artifactId>maven-compiler-plugin</artifactId>" +
540                      "      <version>3.6.0</version>" +
541                      "      <configuration>" +
542                      "        <release>7</release>" +
543                      "      </configuration>" +
544                      "    </plugin>" +
545                      "  </plugins>" +
546                      "</build>");
547
548     importProject();
549
550     assertEquals(LanguageLevel.JDK_1_7, LanguageLevel.parse(getMavenProject().getReleaseLevel()));
551     assertEquals(LanguageLevel.JDK_1_7, LanguageLevelUtil.getCustomLanguageLevel(getModule("project")));
552     assertEquals(LanguageLevel.JDK_1_7,
553                  LanguageLevel.parse(CompilerConfiguration.getInstance(myProject).getBytecodeTargetLevel(getModule("project"))));
554   }
555
556   @Test 
557   public void testCompilerPluginConfigurationCompilerArguments() {
558     importProject("<groupId>test</groupId>" +
559                   "<artifactId>project</artifactId>" +
560                   "<version>1</version>" +
561
562                   "<build>" +
563                   "  <plugins>" +
564                   "    <plugin>" +
565                   "      <groupId>org.apache.maven.plugins</groupId>" +
566                   "      <artifactId>maven-compiler-plugin</artifactId>" +
567                   "      <configuration>" +
568                   "        <compilerArguments>" +
569                   "          <Averbose>true</Averbose>" +
570                   "          <parameters></parameters>" +
571                   "          <bootclasspath>rt.jar_path_here</bootclasspath>" +
572                   "        </compilerArguments>" +
573                   "      </configuration>" +
574                   "    </plugin>" +
575                   "  </plugins>" +
576                   "</build>");
577
578     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
579     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
580     assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")),
581                                     "-Averbose=true", "-parameters", "-bootclasspath", "rt.jar_path_here");
582   }
583
584   @Test
585   public void testCompilerPluginConfigurationCompilerArgumentsParameters() {
586     importProject("<groupId>test</groupId>" +
587                   "<artifactId>project</artifactId>" +
588                   "<version>1</version>" +
589                   "<build>" +
590                   "  <plugins>" +
591                   "    <plugin>" +
592                   "      <groupId>org.apache.maven.plugins</groupId>" +
593                   "      <artifactId>maven-compiler-plugin</artifactId>" +
594                   "      <configuration>" +
595                   "        <parameters>true</parameters>" +
596                   "      </configuration>" +
597                   "    </plugin>" +
598                   "  </plugins>" +
599                   "</build>");
600
601     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
602     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
603     assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")),"-parameters");
604   }
605
606   @Test
607   public void testCompilerPluginConfigurationCompilerArgumentsParametersFalse() {
608     importProject("<groupId>test</groupId>" +
609                   "<artifactId>project</artifactId>" +
610                   "<version>1</version>" +
611                   "<build>" +
612                   "  <plugins>" +
613                   "    <plugin>" +
614                   "      <groupId>org.apache.maven.plugins</groupId>" +
615                   "      <artifactId>maven-compiler-plugin</artifactId>" +
616                   "      <configuration>" +
617                   "        <parameters>false</parameters>" +
618                   "      </configuration>" +
619                   "    </plugin>" +
620                   "  </plugins>" +
621                   "</build>");
622
623     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
624     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
625     assertEmpty(compilerConfiguration.getAdditionalOptions(getModule("project")));
626   }
627
628   @Test
629   public void testCompilerPluginConfigurationCompilerArgumentsParametersPropertyOverride() {
630     importProject("<groupId>test</groupId>" +
631                   "<artifactId>project</artifactId>" +
632                   "<version>1</version>" +
633                   "<properties>" +
634                   "  <maven.compiler.parameters>true</maven.compiler.parameters>" +
635                   "</properties>" +
636                   "<build>" +
637                   "  <plugins>" +
638                   "    <plugin>" +
639                   "      <groupId>org.apache.maven.plugins</groupId>" +
640                   "      <artifactId>maven-compiler-plugin</artifactId>" +
641                   "      <configuration>" +
642                   "        <parameters>false</parameters>" +
643                   "      </configuration>" +
644                   "    </plugin>" +
645                   "  </plugins>" +
646                   "</build>");
647
648     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
649     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
650     assertEmpty(compilerConfiguration.getAdditionalOptions(getModule("project")));
651   }
652
653   @Test
654   public void testCompilerPluginConfigurationCompilerArgumentsParametersPropertyOverride1() {
655     importProject("<groupId>test</groupId>" +
656                   "<artifactId>project</artifactId>" +
657                   "<version>1</version>" +
658                   "<properties>" +
659                   "  <maven.compiler.parameters>false</maven.compiler.parameters>" +
660                   "</properties>" +
661                   "<build>" +
662                   "  <plugins>" +
663                   "    <plugin>" +
664                   "      <groupId>org.apache.maven.plugins</groupId>" +
665                   "      <artifactId>maven-compiler-plugin</artifactId>" +
666                   "      <configuration>" +
667                   "        <parameters>true</parameters>" +
668                   "      </configuration>" +
669                   "    </plugin>" +
670                   "  </plugins>" +
671                   "</build>");
672
673     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
674     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
675     assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")),"-parameters");
676   }
677
678   @Test
679   public void testCompilerPluginConfigurationCompilerArgumentsParametersProperty() {
680     importProject("<groupId>test</groupId>" +
681                   "<artifactId>project</artifactId>" +
682                   "<version>1</version>" +
683                   "<properties>" +
684                   "  <maven.compiler.parameters>true</maven.compiler.parameters>" +
685                   "</properties>" +
686                   "<build>" +
687                   "  <plugins>" +
688                   "    <plugin>" +
689                   "      <groupId>org.apache.maven.plugins</groupId>" +
690                   "      <artifactId>maven-compiler-plugin</artifactId>" +
691                   "    </plugin>" +
692                   "  </plugins>" +
693                   "</build>");
694
695     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
696     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
697     assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")),"-parameters");
698   }
699
700   @Test
701   public void testCompilerPluginConfigurationCompilerArgumentsParametersPropertyFalse() {
702     importProject("<groupId>test</groupId>" +
703                   "<artifactId>project</artifactId>" +
704                   "<version>1</version>" +
705                   "<properties>" +
706                   "  <maven.compiler.parameters>false</maven.compiler.parameters>" +
707                   "</properties>" +
708                   "<build>" +
709                   "  <plugins>" +
710                   "    <plugin>" +
711                   "      <groupId>org.apache.maven.plugins</groupId>" +
712                   "      <artifactId>maven-compiler-plugin</artifactId>" +
713                   "    </plugin>" +
714                   "  </plugins>" +
715                   "</build>");
716
717     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
718     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
719     assertEmpty(compilerConfiguration.getAdditionalOptions(getModule("project")));
720   }
721
722   @Test 
723   public void testCompilerPluginConfigurationUnresolvedCompilerArguments() {
724     importProject("<groupId>test</groupId>" +
725                   "<artifactId>project</artifactId>" +
726                   "<version>1</version>" +
727
728                   "<build>" +
729                   "  <plugins>" +
730                   "    <plugin>" +
731                   "      <groupId>org.apache.maven.plugins</groupId>" +
732                   "      <artifactId>maven-compiler-plugin</artifactId>" +
733                   "      <configuration>" +
734                   "        <compilerId>${maven.compiler.compilerId}</compilerId>" +
735                   "        <compilerArgument>${unresolvedArgument}</compilerArgument>" +
736                   "        <compilerArguments>" +
737                   "          <d>path/with/braces_${</d>" +
738                   "          <anotherStrangeArg>${_${foo}</anotherStrangeArg>" +
739                   "        </compilerArguments>" +
740                   "        <compilerArgs>" +
741                   "          <arg>${anotherUnresolvedArgument}</arg>" +
742                   "          <arg>-myArg</arg>" +
743                   "        </compilerArgs>" +
744                   "      </configuration>" +
745                   "    </plugin>" +
746                   "  </plugins>" +
747                   "</build>");
748
749     CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
750     assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
751     assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")),
752                                     "-myArg", "-d", "path/with/braces_${");
753   }
754
755   // commenting the test as the errorProne module is not available to IJ community project
756   // TODO move the test to the errorProne module
757   //public void stestCompilerPluginErrorProneConfiguration() {
758   //  importProject("<groupId>test</groupId>" +
759   //                "<artifactId>project</artifactId>" +
760   //                "<version>1</version>" +
761   //
762   //                "<build>" +
763   //                "  <plugins>" +
764   //                "    <plugin>" +
765   //                "      <groupId>org.apache.maven.plugins</groupId>" +
766   //                "      <artifactId>maven-compiler-plugin</artifactId>" +
767   //                "      <configuration>" +
768   //                "        <compilerId>javac-with-errorprone</compilerId>" +
769   //                "        <compilerArgs>" +
770   //                "          <arg>-XepAllErrorsAsWarnings</arg>" +
771   //                "        </compilerArgs>" +
772   //                "      </configuration>" +
773   //                "    </plugin>" +
774   //                "  </plugins>" +
775   //                "</build>");
776   //
777   //  CompilerConfigurationImpl compilerConfiguration = (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject);
778   //  assertEquals("error-prone", compilerConfiguration.getDefaultCompiler().getId());
779   //  assertUnorderedElementsAreEqual(compilerConfiguration.getAdditionalOptions(getModule("project")), "-XepAllErrorsAsWarnings");
780   //
781   //  importProject("<groupId>test</groupId>" +
782   //                "<artifactId>project</artifactId>" +
783   //                "<version>1</version>");
784   //
785   //  assertEquals("Javac", compilerConfiguration.getDefaultCompiler().getId());
786   //  assertEmpty(compilerConfiguration.getAdditionalOptions(getModule("project")));
787   //}
788
789   @Test 
790   public void testMergingPluginConfigurationFromBuildProfilesAndPluginsManagement() {
791     createProjectPom("<groupId>test</groupId>" +
792                      "<artifactId>project</artifactId>" +
793                      "<version>1</version>" +
794
795                      "<profiles>" +
796                      "  <profile>" +
797                      "    <id>one</id>" +
798                      "    <build>" +
799                      "      <plugins>" +
800                      "        <plugin>" +
801                      "          <groupId>org.apache.maven.plugins</groupId>" +
802                      "          <artifactId>maven-compiler-plugin</artifactId>" +
803                      "          <configuration>" +
804                      "            <target>1.4</target>" +
805                      "          </configuration>" +
806                      "        </plugin>" +
807                      "      </plugins>" +
808                      "    </build>" +
809                      "  </profile>" +
810                      "</profiles>" +
811
812                      "<build>" +
813                      "  <plugins>" +
814                      "    <plugin>" +
815                      "      <groupId>org.apache.maven.plugins</groupId>" +
816                      "      <artifactId>maven-compiler-plugin</artifactId>" +
817                      "      <configuration>" +
818                      "        <debug>true</debug>" +
819                      "      </configuration>" +
820                      "    </plugin>" +
821                      "  </plugins>" +
822                      "  <pluginManagement>" +
823                      "    <plugins>" +
824                      "      <plugin>" +
825                      "        <groupId>org.apache.maven.plugins</groupId>" +
826                      "        <artifactId>maven-compiler-plugin</artifactId>" +
827                      "        <configuration>" +
828                      "          <source>1.4</source>" +
829                      "        </configuration>" +
830                      "      </plugin>" +
831                      "    </plugins>" +
832                      "  </pluginManagement>" +
833                      "</build>");
834     importProjectWithProfiles("one");
835
836     MavenPlugin plugin = findPlugin("org.apache.maven.plugins", "maven-compiler-plugin");
837     assertEquals("1.4", plugin.getConfigurationElement().getChildText("source"));
838     assertEquals("1.4", plugin.getConfigurationElement().getChildText("target"));
839     assertEquals("true", plugin.getConfigurationElement().getChildText("debug"));
840   }
841
842   @Test 
843   public void testDoesNotCollectProfilesWithoutId() {
844     importProject("<groupId>test</groupId>" +
845                   "<artifactId>project</artifactId>" +
846                   "<version>1</version>" +
847
848                   "<profiles>" +
849                   "  <profile>" +
850                   "    <id>one</id>" +
851                   "  </profile>" +
852                   "  <profile>" +
853                   "  </profile>" +
854                   "</profiles>");
855
856     assertUnorderedElementsAreEqual(getMavenProject().getProfilesIds(), "one", "default");
857   }
858
859   @Test 
860   public void testCollectingRepositories() {
861     importProject("<groupId>test</groupId>" +
862                   "<artifactId>project</artifactId>" +
863                   "<version>1</version>" +
864
865                   "<repositories>" +
866                   "  <repository>" +
867                   "    <id>one</id>" +
868                   "    <url>https://repository.one.com</url>" +
869                   "  </repository>" +
870                   "  <repository>" +
871                   "    <id>two</id>" +
872                   "    <url>https://repository.two.com</url>" +
873                   "  </repository>" +
874                   "</repositories>");
875
876     List<MavenRemoteRepository> result = getMavenProject().getRemoteRepositories();
877     assertEquals(3, result.size());
878     assertEquals("one", result.get(0).getId());
879     assertEquals("two", result.get(1).getId());
880     assertEquals("central", result.get(2).getId());
881   }
882
883   @Test 
884   public void testOverridingCentralRepository() {
885     importProject("<groupId>test</groupId>" +
886                   "<artifactId>project</artifactId>" +
887                   "<version>1</version>" +
888
889                   "<repositories>" +
890                   "  <repository>" +
891                   "    <id>central</id>" +
892                   "    <url>https://my.repository.com</url>" +
893                   "  </repository>" +
894                   "</repositories>");
895
896     List<MavenRemoteRepository> result = getMavenProject().getRemoteRepositories();
897     assertEquals(1, result.size());
898     assertEquals("central", result.get(0).getId());
899     assertEquals("https://my.repository.com", result.get(0).getUrl());
900   }
901
902   @Test 
903   public void testCollectingRepositoriesFromParent() {
904     VirtualFile m1 = createModulePom("p1",
905                                      "<groupId>test</groupId>" +
906                                      "<artifactId>p1</artifactId>" +
907                                      "<version>1</version>" +
908                                      "<packaging>pom</packaging>" +
909
910                                      "<repositories>" +
911                                      "  <repository>" +
912                                      "    <id>one</id>" +
913                                      "    <url>https://repository.one.com</url>" +
914                                      "  </repository>" +
915                                      "  <repository>" +
916                                      "    <id>two</id>" +
917                                      "    <url>https://repository.two.com</url>" +
918                                      "  </repository>" +
919                                      "</repositories>");
920
921     VirtualFile m2 = createModulePom("p2",
922                                      "<groupId>test</groupId>" +
923                                      "<artifactId>p2</artifactId>" +
924                                      "<version>1</version>" +
925
926                                      "<parent>" +
927                                      "  <groupId>test</groupId>" +
928                                      "  <artifactId>p1</artifactId>" +
929                                      "  <version>1</version>" +
930                                      "</parent>");
931
932     importProjects(m1, m2);
933
934     List<MavenRemoteRepository> result = myProjectsTree.getRootProjects().get(0).getRemoteRepositories();
935     assertEquals(3, result.size());
936     assertEquals("one", result.get(0).getId());
937     assertEquals("two", result.get(1).getId());
938     assertEquals("central", result.get(2).getId());
939
940     result = myProjectsTree.getRootProjects().get(1).getRemoteRepositories();
941     assertEquals(3, result.size());
942     assertEquals("one", result.get(0).getId());
943     assertEquals("two", result.get(1).getId());
944     assertEquals("central", result.get(2).getId());
945   }
946
947   @Test
948   public void testResolveRemoteRepositories() throws IOException {
949     updateSettingsXml("<mirrors>\n" +
950                       "  <mirror>\n" +
951                       "    <id>mirror</id>\n" +
952                       "    <url>https://test/mirror</url>\n" +
953                       "    <mirrorOf>repo,repo-pom</mirrorOf>\n" +
954                       "  </mirror>\n" +
955                       "</mirrors>\n" +
956                       "<profiles>\n" +
957                       "  <profile>\n" +
958                       "    <id>repo-test</id>\n" +
959                       "    <repositories>\n" +
960                       "      <repository>" +
961                       "        <id>repo</id>" +
962                       "        <url>https://settings/repo</url>" +
963                       "      </repository>" +
964                       "      <repository>" +
965                       "        <id>repo1</id>" +
966                       "        <url>https://settings/repo1</url>" +
967                       "      </repository>" +
968                       "    </repositories>\n" +
969                       "  </profile>\n" +
970                       "</profiles>\n" +
971                       "<activeProfiles>\n" +
972                       "   <activeProfile>repo-test</activeProfile>\n" +
973                       "</activeProfiles>");
974
975     VirtualFile projectPom = createProjectPom("<groupId>test</groupId>" +
976                                               "<artifactId>test</artifactId>" +
977                                               "<version>1</version>" +
978
979                                               "<repositories>\n" +
980                                               "  <repository>\n" +
981                                               "    <id>repo-pom</id>" +
982                                               "    <url>https://pom/repo</url>" +
983                                               "  </repository>\n" +
984                                               "  <repository>\n" +
985                                               "    <id>repo-pom1</id>" +
986                                               "    <url>https://pom/repo1</url>" +
987                                               "  </repository>\n" +
988                                               "</repositories>");
989     importProject();
990
991     MavenProject project = MavenProjectsManager.getInstance(myProject).findProject(projectPom);
992     Assert.assertNotNull(project);
993     Set<String> repoIds = project.getRemoteRepositories().stream()
994       .map(r -> r.getId())
995       .collect(Collectors.toSet());
996     System.out.println(repoIds);
997     Assert.assertTrue(repoIds.contains("mirror"));
998     Assert.assertTrue(repoIds.contains("repo-pom1"));
999     Assert.assertTrue(repoIds.contains("repo1"));
1000     Assert.assertFalse(repoIds.contains("repo-pom"));
1001     Assert.assertFalse(repoIds.contains("repo"));
1002   }
1003
1004   @Test 
1005   public void testMavenModelMap() {
1006     importProject("<groupId>test</groupId>" +
1007                   "<artifactId>project</artifactId>" +
1008                   "<version>1</version>" +
1009                   "<build>" +
1010                   "  <finalName>foo</finalName>" +
1011                   "  <plugins>" +
1012                   "    <plugin>" +
1013                   "      <groupId>group1</groupId>" +
1014                   "      <artifactId>id1</artifactId>" +
1015                   "      <version>1</version>" +
1016                   "    </plugin>" +
1017                   "  </plugins>" +
1018                   "</build>");
1019
1020     MavenProject p = getMavenProject();
1021     Map<String,String> map = p.getModelMap();
1022
1023     assertEquals("test", map.get("groupId"));
1024     assertEquals("foo", map.get("build.finalName"));
1025     assertEquals(new File(p.getDirectory(), "target").toString(), map.get("build.directory"));
1026     assertNull(map.get("build.plugins"));
1027     assertNull(map.get("build.pluginMap"));
1028   }
1029
1030   @Test 
1031   public void testDependenciesTree() {
1032     VirtualFile m1 = createModulePom("p1",
1033                                      "<groupId>test</groupId>" +
1034                                      "<artifactId>m1</artifactId>" +
1035                                      "<version>1</version>" +
1036
1037                                      "<dependencies>" +
1038                                      "  <dependency>" +
1039                                      "    <groupId>test</groupId>" +
1040                                      "    <artifactId>m2</artifactId>" +
1041                                      "    <version>1</version>" +
1042                                      "  </dependency>" +
1043                                      "  <dependency>" +
1044                                      "    <groupId>test</groupId>" +
1045                                      "    <artifactId>lib1</artifactId>" +
1046                                      "    <version>1</version>" +
1047                                      "  </dependency>" +
1048                                      "</dependencies>");
1049
1050     VirtualFile m2 = createModulePom("p2",
1051                                      "<groupId>test</groupId>" +
1052                                      "<artifactId>m2</artifactId>" +
1053                                      "<version>1</version>" +
1054
1055                                      "<dependencies>" +
1056                                      "  <dependency>" +
1057                                      "    <groupId>junit</groupId>" +
1058                                      "    <artifactId>junit</artifactId>" +
1059                                      "    <version>4.0</version>" +
1060                                      "  </dependency>" +
1061                                      "  <dependency>" +
1062                                      "    <groupId>test</groupId>" +
1063                                      "    <artifactId>lib2</artifactId>" +
1064                                      "    <version>1</version>" +
1065                                      "  </dependency>" +
1066                                      "</dependencies>");
1067
1068     importProjects(m1, m2);
1069     resolveDependenciesAndImport();
1070
1071     assertDependenciesNodes(myProjectsTree.getRootProjects().get(0).getDependencyTree(),
1072                             "test:m2:jar:1->(junit:junit:jar:4.0->(),test:lib2:jar:1->()),test:lib1:jar:1->()");
1073   }
1074
1075   @Test 
1076   public void testDependenciesTreeWithTypesAndClassifiers() {
1077     VirtualFile m1 = createModulePom("p1",
1078                                      "<groupId>test</groupId>" +
1079                                      "<artifactId>m1</artifactId>" +
1080                                      "<version>1</version>" +
1081
1082                                      "<dependencies>" +
1083                                      "  <dependency>" +
1084                                      "    <groupId>test</groupId>" +
1085                                      "    <artifactId>m2</artifactId>" +
1086                                      "    <version>1</version>" +
1087                                      "    <type>pom</type>" +
1088                                      "    <classifier>test</classifier>" +
1089                                      "  </dependency>" +
1090                                      "</dependencies>");
1091
1092     VirtualFile m2 = createModulePom("p2",
1093                                      "<groupId>test</groupId>" +
1094                                      "<artifactId>m2</artifactId>" +
1095                                      "<version>1</version>" +
1096
1097                                      "<dependencies>" +
1098                                      "  <dependency>" +
1099                                      "    <groupId>test</groupId>" +
1100                                      "    <artifactId>lib</artifactId>" +
1101                                      "    <version>1</version>" +
1102                                      "  </dependency>" +
1103                                      "</dependencies>");
1104
1105     importProjects(m1, m2);
1106     resolveDependenciesAndImport();
1107
1108     assertDependenciesNodes(myProjectsTree.getRootProjects().get(0).getDependencyTree(),
1109                             "test:m2:pom:test:1->(test:lib:jar:1->())");
1110   }
1111
1112   @Test 
1113   public void testDependenciesTreeWithConflict() {
1114     VirtualFile m1 = createModulePom("p1",
1115                                      "<groupId>test</groupId>" +
1116                                      "<artifactId>m1</artifactId>" +
1117                                      "<version>1</version>" +
1118
1119                                      "<dependencies>" +
1120                                      "  <dependency>" +
1121                                      "    <groupId>test</groupId>" +
1122                                      "    <artifactId>m2</artifactId>" +
1123                                      "    <version>1</version>" +
1124                                      "  </dependency>" +
1125                                      "  <dependency>" +
1126                                      "    <groupId>test</groupId>" +
1127                                      "    <artifactId>lib</artifactId>" +
1128                                      "    <version>1</version>" +
1129                                      "  </dependency>" +
1130                                      "</dependencies>");
1131
1132     VirtualFile m2 = createModulePom("p2",
1133                                      "<groupId>test</groupId>" +
1134                                      "<artifactId>m2</artifactId>" +
1135                                      "<version>1</version>" +
1136
1137                                      "<dependencies>" +
1138                                      "  <dependency>" +
1139                                      "    <groupId>test</groupId>" +
1140                                      "    <artifactId>lib</artifactId>" +
1141                                      "    <version>2</version>" +
1142                                      "  </dependency>" +
1143                                      "</dependencies>");
1144
1145     importProjects(m1, m2);
1146     resolveDependenciesAndImport();
1147
1148     List<MavenArtifactNode> nodes = myProjectsTree.getRootProjects().get(0).getDependencyTree();
1149     assertDependenciesNodes(nodes,
1150                             "test:m2:jar:1->(test:lib:jar:2[CONFLICT:test:lib:jar:1]->())," +
1151                             "test:lib:jar:1->()");
1152     assertSame(nodes.get(0).getDependencies().get(0).getRelatedArtifact(),
1153                nodes.get(1).getArtifact());
1154   }
1155
1156   @Test 
1157   public void testDependencyTreeDuplicates() {
1158     VirtualFile m1 = createModulePom("p1",
1159                                      "<groupId>test</groupId>" +
1160                                      "<artifactId>m1</artifactId>" +
1161                                      "<version>1</version>" +
1162
1163                                      "<dependencies>" +
1164                                      "  <dependency>" +
1165                                      "    <groupId>test</groupId>" +
1166                                      "    <artifactId>m2</artifactId>" +
1167                                      "    <version>1</version>" +
1168                                      "  </dependency>" +
1169                                      "  <dependency>" +
1170                                      "    <groupId>test</groupId>" +
1171                                      "    <artifactId>m3</artifactId>" +
1172                                      "    <version>1</version>" +
1173                                      "  </dependency>" +
1174                                      "</dependencies>");
1175
1176     VirtualFile m2 = createModulePom("p2",
1177                                      "<groupId>test</groupId>" +
1178                                      "<artifactId>m2</artifactId>" +
1179                                      "<version>1</version>" +
1180
1181                                      "<dependencies>" +
1182                                      "  <dependency>" +
1183                                      "    <groupId>test</groupId>" +
1184                                      "    <artifactId>lib</artifactId>" +
1185                                      "    <version>1</version>" +
1186                                      "  </dependency>" +
1187                                      "</dependencies>");
1188
1189     VirtualFile m3 = createModulePom("p3",
1190                                      "<groupId>test</groupId>" +
1191                                      "<artifactId>m3</artifactId>" +
1192                                      "<version>1</version>" +
1193
1194                                      "<dependencies>" +
1195                                      "  <dependency>" +
1196                                      "    <groupId>test</groupId>" +
1197                                      "    <artifactId>lib</artifactId>" +
1198                                      "    <version>1</version>" +
1199                                      "  </dependency>" +
1200                                      "</dependencies>");
1201
1202     importProjects(m1, m2, m3);
1203     resolveDependenciesAndImport();
1204
1205     List<MavenArtifactNode> nodes = myProjectsTree.findProject(m1).getDependencyTree();
1206     assertDependenciesNodes(nodes, "test:m2:jar:1->(test:lib:jar:1->()),test:m3:jar:1->(test:lib:jar:1[DUPLICATE:test:lib:jar:1]->())");
1207
1208     assertSame(nodes.get(0).getDependencies().get(0).getArtifact(),
1209                nodes.get(1).getDependencies().get(0).getRelatedArtifact());
1210   }
1211
1212   protected void assertDependenciesNodes(List<MavenArtifactNode> nodes, String expected) {
1213     assertEquals(expected, StringUtil.join(nodes, ","));
1214   }
1215
1216   private String findPluginConfig(String groupId, String artifactId, String path) {
1217     return MavenJDOMUtil.findChildValueByPath(getMavenProject().getPluginConfiguration(groupId, artifactId), path);
1218   }
1219
1220   private String findPluginGoalConfig(String groupId, String artifactId, String goal, String path) {
1221     return MavenJDOMUtil.findChildValueByPath(getMavenProject().getPluginGoalConfiguration(groupId, artifactId, goal), path);
1222   }
1223
1224   private void assertDeclaredPlugins(PluginInfo... expected) {
1225     List<PluginInfo> defaultPlugins = Arrays.asList(
1226       p("org.apache.maven.plugins", "maven-site-plugin"),
1227       p("org.apache.maven.plugins", "maven-deploy-plugin"),
1228       p("org.apache.maven.plugins", "maven-compiler-plugin"),
1229       p("org.apache.maven.plugins", "maven-install-plugin"),
1230       p("org.apache.maven.plugins", "maven-jar-plugin"),
1231       p("org.apache.maven.plugins", "maven-clean-plugin"),
1232       p("org.apache.maven.plugins", "maven-resources-plugin"),
1233       p("org.apache.maven.plugins", "maven-surefire-plugin"));
1234     List<PluginInfo> expectedList = new ArrayList<>();
1235     expectedList.addAll(defaultPlugins);
1236     expectedList.addAll(Arrays.asList(expected));
1237     assertUnorderedElementsAreEqual(p(getMavenProject().getDeclaredPlugins()), expectedList);
1238   }
1239
1240   private MavenPlugin findPlugin(String groupId, String artifactId) {
1241     return getMavenProject().findPlugin(groupId, artifactId);
1242   }
1243
1244   private MavenProject getMavenProject() {
1245     return myProjectsTree.getRootProjects().get(0);
1246   }
1247
1248   private static PluginInfo p(String groupId, String artifactId) {
1249     return new PluginInfo(groupId, artifactId);
1250   }
1251
1252   private static PluginInfo p(MavenPlugin mavenPlugin) {
1253     return new PluginInfo(mavenPlugin.getGroupId(), mavenPlugin.getArtifactId());
1254   }
1255
1256   private List<PluginInfo> p(Collection<MavenPlugin> mavenPlugins) {
1257     List<PluginInfo> res = new ArrayList<>(mavenPlugins.size());
1258     for (MavenPlugin mavenPlugin : mavenPlugins) {
1259       res.add(p(mavenPlugin));
1260     }
1261
1262     return res;
1263   }
1264
1265   private static final class PluginInfo {
1266     String groupId;
1267     String artifactId;
1268
1269     private PluginInfo(String groupId, String artifactId) {
1270       this.groupId = groupId;
1271       this.artifactId = artifactId;
1272     }
1273
1274     @Override
1275     public String toString() {
1276       return groupId + ":" + artifactId;
1277     }
1278
1279     @Override
1280     public boolean equals(Object o) {
1281       if (this == o) return true;
1282       if (o == null || getClass() != o.getClass()) return false;
1283
1284       PluginInfo info = (PluginInfo)o;
1285
1286       if (artifactId != null ? !artifactId.equals(info.artifactId) : info.artifactId != null) return false;
1287       if (groupId != null ? !groupId.equals(info.groupId) : info.groupId != null) return false;
1288
1289       return true;
1290     }
1291
1292     @Override
1293     public int hashCode() {
1294       int result = groupId != null ? groupId.hashCode() : 0;
1295       result = 31 * result + (artifactId != null ? artifactId.hashCode() : 0);
1296       return result;
1297     }
1298   }
1299 }