Search in sources :

Example 11 with MavenCustomRepositoryHelper

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

the class InvalidProjectImportingTest method testDoNotReportResolvedPlugins.

public void testDoNotReportResolvedPlugins() throws Exception {
    MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "plugins");
    setRepositoryPath(helper.getTestDataPath("plugins"));
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + " <plugins>" + "   <plugin>" + "     <groupId>org.apache.maven.plugins</groupId>" + "     <artifactId>maven-compiler-plugin</artifactId>" + "     <version>2.0.2</version>" + "    </plugin>" + "  </plugins>" + "</build>");
    assertProblems(getRootProjects().get(0));
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper)

Example 12 with MavenCustomRepositoryHelper

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

the class MiscImportingTest method testMavenExtensionsAreLoadedAndAfterProjectsReadIsCalled.

public void testMavenExtensionsAreLoadedAndAfterProjectsReadIsCalled() throws Exception {
    try {
        MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "plugins");
        setRepositoryPath(helper.getTestDataPath("plugins"));
        getMavenGeneralSettings().setWorkOffline(true);
        importProjectWithMaven3("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "" + "<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("Name for test:project generated by MyMavenExtension.", mavenProject.getFinalName());
        PlatformTestUtil.assertPathsEqual(myProjectPom.getPath(), mavenProject.getProperties().getProperty("workspace-info"));
    } finally {
        // do not lock files by maven process
        MavenServerManager.getInstance().shutdown(true);
    }
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 13 with MavenCustomRepositoryHelper

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

the class MiscImportingTest method testTakingProxySettingsIntoAccount.

public void testTakingProxySettingsIntoAccount() throws Exception {
    MavenCustomRepositoryHelper helper = new MavenCustomRepositoryHelper(myDir, "local1");
    setRepositoryPath(helper.getTestDataPath("local1"));
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<dependencies>" + "  <dependency>" + "    <groupId>junit</groupId>" + "    <artifactId>junit</artifactId>" + "    <version>4.0</version>" + "  </dependency>" + "</dependencies>");
    removeFromLocalRepository("junit");
    // force resolving
    scheduleResolveAll();
    resolveDependenciesAndImport();
    File jarFile = new File(getRepositoryFile(), "junit/junit/4.0/junit-4.0.jar");
    assertTrue(jarFile.exists());
    myProjectsManager.listenForExternalChanges();
    // valid password is 'fg3W9' (see http://www.jetbrains.net/confluence/display/JBINT/HTTP+Proxy+with+authorization)
    updateSettingsXml("<proxies>" + " <proxy>" + "    <id>my</id>" + "    <active>true</active>" + "    <protocol>http</protocol>" + "    <host>proxy-auth-test.labs.intellij.net</host>" + "    <port>3128</port>" + "    <username>user1</username>" + "    <password>invalid</password>" + "  </proxy>" + "</proxies>");
    removeFromLocalRepository("junit");
    assertFalse(jarFile.exists());
    try {
        // force resolving
        scheduleResolveAll();
        resolveDependenciesAndImport();
    } finally {
        // LightweightHttpWagon does not clear settings if they were not set before a proxy was configured.
        System.clearProperty("http.proxyHost");
        System.clearProperty("http.proxyPort");
    }
    assertFalse(jarFile.exists());
    restoreSettingsFile();
    // force resolving
    scheduleResolveAll();
    resolveDependenciesAndImport();
    assertTrue(jarFile.exists());
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) File(java.io.File)

Example 14 with MavenCustomRepositoryHelper

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

the class MavenIndicesStressTest method test2.

public void test2() throws Exception {
    MavenCustomRepositoryHelper helper;
    helper = new MavenCustomRepositoryHelper(myDir, "plugins", "local1", "local2");
    helper.copy("plugins", "local1");
    helper.copy("local2", "local1");
    setRepositoryPath(helper.getTestDataPath("local1"));
    final MavenIndexerWrapper indexer = MavenServerManager.getInstance().createIndexer();
    File indicesDir = new File(myDir, "indices");
    MavenIndices indices = new MavenIndices(indexer, indicesDir, this);
    MavenIndex index = indices.add("id", getRepositoryPath(), MavenIndex.Kind.LOCAL);
    //index.addArtifact(new MavenId("group1", "artifact1", "1"));
    fail();
    indices.close();
    MavenIndices indices1 = new MavenIndices(indexer, indicesDir, this);
    MavenIndices indices2 = new MavenIndices(indexer, indicesDir, this);
    AtomicInteger finishedCount = new AtomicInteger(0);
    Thread t1 = createThread(indices1.getIndices().get(0), finishedCount);
    Thread t2 = createThread(indices2.getIndices().get(0), finishedCount);
    t1.start();
    t2.start();
    do {
        t1.join(100);
        t2.join(100);
    } while (finishedCount.get() < 2);
    t1.join(100);
    t2.join(100);
    indices.close();
    indices1.close();
    indices2.close();
    t1.join();
    t2.join();
}
Also used : MavenCustomRepositoryHelper(org.jetbrains.idea.maven.MavenCustomRepositoryHelper) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MavenIndexerWrapper(org.jetbrains.idea.maven.server.MavenIndexerWrapper) File(java.io.File)

Example 15 with MavenCustomRepositoryHelper

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

the class MavenIndicesTestFixture method setUp.

public void setUp() throws Exception {
    myRepositoryHelper = new MavenCustomRepositoryHelper(myDir.toFile(), ArrayUtil.append(myExtraRepoDirs, myLocalRepoDir));
    for (String each : myExtraRepoDirs) {
        addToRepository(each);
    }
    MavenProjectsManager.getInstance(myProject).getGeneralSettings().setLocalRepository(myRepositoryHelper.getTestDataPath(myLocalRepoDir));
    getIndicesManager().setTestIndexDir(myDir.resolve("MavenIndices"));
    myIndicesManager = MavenProjectIndicesManager.getInstance(myProject);
    myIndicesManager.doInit();
}
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