Search in sources :

Example 6 with MavenCustomRepositoryHelper

use of org.jetbrains.idea.maven.MavenCustomRepositoryHelper in project intellij-community by JetBrains.

the class MavenIndicesStressTest method test1.

public void test1() throws Exception {
    MavenCustomRepositoryHelper helper;
    helper = new MavenCustomRepositoryHelper(myDir, "plugins", "local1", "local2");
    helper.copy("plugins", "local1");
    helper.copy("local2", "local1");
    //setRepositoryPath(fixture.getTestDataPath("local1"));
    final MavenIndexerWrapper indexer = MavenServerManager.getInstance().createIndexer();
    File indicesDir = new File(myDir, "indices");
    final MavenIndices indices = new MavenIndices(indexer, indicesDir, this);
    final MavenIndex index = indices.add("id", getRepositoryPath(), MavenIndex.Kind.LOCAL);
    final AtomicBoolean isFinished = new AtomicBoolean(false);
    Thread t1 = new Thread(() -> {
        try {
            for (int i = 0; i < 3; i++) {
                System.out.println("INDEXING #" + i);
                indices.updateOrRepair(index, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
            }
        } catch (MavenProcessCanceledException e) {
            throw new RuntimeException(e);
        } finally {
            isFinished.set(true);
        }
    }, "maven index 1");
    Thread t2 = new Thread(() -> {
        Random random = new Random();
        while (!isFinished.get()) {
            int i = random.nextInt(100);
            System.out.println("Adding artifact #" + i);
            //index.addArtifact(new MavenId("group" + i, "artifact" + i, "" + i));
            fail();
        }
    }, "maven index 2");
    t1.start();
    t2.start();
    do {
        t1.join(100);
        t2.join(100);
    } while (!isFinished.get());
    t1.join(100);
    t2.join(100);
    indices.close();
    t1.join();
    t2.join();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) Random(java.util.Random) MavenIndexerWrapper(org.jetbrains.idea.maven.server.MavenIndexerWrapper) File(java.io.File)

Example 7 with MavenCustomRepositoryHelper

use of org.jetbrains.idea.maven.MavenCustomRepositoryHelper in project intellij-community by JetBrains.

the class MavenIndicesTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    updateSettingsXmlFully("<settings>" + "  <mirrors>" + "  </mirrors>" + "</settings>");
    myRepositoryHelper = new MavenCustomRepositoryHelper(myDir, "local1", "local2", "remote");
    initIndices();
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper)

Example 8 with MavenCustomRepositoryHelper

use of org.jetbrains.idea.maven.MavenCustomRepositoryHelper in project intellij-community by JetBrains.

the class MiscImportingTest method testExceptionsFromMavenExtensionsAreReportedAsProblems.

public void testExceptionsFromMavenExtensionsAreReportedAsProblems() throws Exception {
    MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "plugins");
    setRepositoryPath(helper.getTestDataPath("plugins"));
    getMavenGeneralSettings().setWorkOffline(true);
    importProjectWithMaven3("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<description>throw!</description>" + "" + "<build>" + "  <extensions>" + "    <extension>" + "      <groupId>intellij.test</groupId>" + "      <artifactId>maven-extension</artifactId>" + "      <version>1.0</version>" + "    </extension>" + "  </extensions>" + "</build>");
    List<MavenProject> projects = myProjectsTree.getProjects();
    assertEquals(1, projects.size());
    MavenProject mavenProject = projects.get(0);
    assertEquals(mavenProject.getProblems().toString(), 1, mavenProject.getProblems().size());
    assertEquals("throw!", mavenProject.getProblems().get(0).getDescription());
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 9 with MavenCustomRepositoryHelper

use of org.jetbrains.idea.maven.MavenCustomRepositoryHelper in project intellij-community by JetBrains.

the class FoldersImportingTest method testDownloadingNecessaryPlugins.

public void testDownloadingNecessaryPlugins() throws Exception {
    try {
        MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "local1");
        setRepositoryPath(helper.getTestDataPath("local1"));
        File pluginFile = new File(getRepositoryPath(), "org/codehaus/mojo/build-helper-maven-plugin/1.2/build-helper-maven-plugin-1.2.jar");
        assertFalse(pluginFile.exists());
        importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <groupId>org.codehaus.mojo</groupId>" + "      <artifactId>build-helper-maven-plugin</artifactId>" + "      <version>1.2</version>" + "      <executions>" + "        <execution>" + "          <id>someId</id>" + "          <phase>generate-sources</phase>" + "          <goals>" + "            <goal>add-source</goal>" + "          </goals>" + "          <configuration>" + "            <sources>" + "              <source>src</source>" + "            </sources>" + "          </configuration>" + "        </execution>" + "      </executions>" + "    </plugin>" + "  </plugins>" + "</build>");
        resolveDependenciesAndImport();
        resolveFoldersAndImport();
        assertTrue(pluginFile.exists());
    } finally {
        // do not lock files by maven process
        MavenServerManager.getInstance().shutdown(true);
    }
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 10 with MavenCustomRepositoryHelper

use of org.jetbrains.idea.maven.MavenCustomRepositoryHelper in project intellij-community by JetBrains.

the class DependenciesImportingTest method testVersionRangeInDependencyManagementDoesntBreakIndirectDependency.

//public void testVersionRangeDoesntBreakIndirectDependency() throws Exception {
//  createProjectPom("<groupId>test</groupId>" +
//                   "<artifactId>project</artifactId>" +
//                   "<version>1</version>" +
//                   "<packaging>pom</packaging>" +
//
//                   "<modules>" +
//                   "  <module>m1</module>" +
//                   "  <module>m2</module>" +
//                   "</modules>");
//
//  createModulePom("m1", "<groupId>test</groupId>" +
//                        "<artifactId>m1</artifactId>" +
//                        "<version>1</version>" +
//
//                        "<dependencies>" +
//                        "  <dependency>" +
//                        "    <groupId>asm</groupId>" +
//                        "    <artifactId>asm</artifactId>" +
//                        "    <version>2.2.3</version>" +
//                        "  </dependency>" +
//                        "</dependencies>");
//
//  createModulePom("m2", "<groupId>test</groupId>" +
//                        "<artifactId>m2</artifactId>" +
//                        "<version>1</version>" +
//
//                        "<dependencies>" +
//                        "  <dependency>" +
//                        "    <groupId>test</groupId>" +
//                        "    <artifactId>m1</artifactId>" +
//                        "    <version>1</version>" +
//                        "  </dependency>" +
//                        "  <dependency>" +
//                        "    <groupId>asm</groupId>" +
//                        "    <artifactId>asm</artifactId>" +
//                        "    <version>[2.2.3]</version>" +
//                        "  </dependency>" +
//                        "</dependencies>");
//
//  importProject();
//
//  assertModuleModuleDeps("m2", "m1");
//  assertModuleLibDeps("m1", "Maven: asm:asm:2.2.3");
//  assertModuleLibDeps("m2", "Maven: asm:asm:2.2.3");
//}
//
public void testVersionRangeInDependencyManagementDoesntBreakIndirectDependency() throws Exception {
    MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "local1");
    String repoPath = helper.getTestDataPath("local1");
    setRepositoryPath(repoPath);
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>m</module>" + "</modules>" + "     <dependencyManagement>\n" + "         <dependencies>\n" + "              <dependency>\n" + "                 <artifactId>asm</artifactId>\n" + "                 <groupId>asm</groupId>\n" + "                 <version>[2.2.1]</version>\n" + "                 <scope>runtime</scope>\n" + "             </dependency>\n" + "             <dependency>\n" + "                 <artifactId>asm-attrs</artifactId>\n" + "                 <groupId>asm</groupId>\n" + "                 <version>[2.2.1]</version>\n" + "                 <scope>runtime</scope>\n" + "             </dependency>\n" + "         </dependencies>\n" + "     </dependencyManagement>");
    createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>" + "" + "    <parent>\n" + "        <groupId>test</groupId>\n" + "        <artifactId>project</artifactId>\n" + "        <version>1</version>\n" + "    </parent>" + "<dependencies>" + "  <dependency>" + "            <artifactId>asm-attrs</artifactId>\n" + "            <groupId>asm</groupId>\n" + "            <scope>test</scope>" + "  </dependency>" + "</dependencies>");
    importProject();
    assertModuleLibDeps("m", "Maven: asm:asm-attrs:2.2.1", "Maven: asm:asm:2.2.1");
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper)

Aggregations

MavenCustomRepositoryHelper (org.jetbrains.idea.maven.MavenCustomRepositoryHelper)15 File (java.io.File)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 MavenProject (org.jetbrains.idea.maven.project.MavenProject)2 MavenIndexerWrapper (org.jetbrains.idea.maven.server.MavenIndexerWrapper)2 Random (java.util.Random)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MavenProcessCanceledException (org.jetbrains.idea.maven.utils.MavenProcessCanceledException)1 IndexUpdater (org.sonatype.nexus.index.updater.IndexUpdater)1