Search in sources :

Example 6 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project android by JetBrains.

the class AndroidJpsUtil method getAndroidArtifactsToBuild.

@NotNull
public static List<JpsArtifact> getAndroidArtifactsToBuild(@NotNull CompileContext context) {
    final List<JpsArtifact> artifacts = JpsArtifactService.getInstance().getArtifacts(context.getProjectDescriptor().getProject());
    final List<JpsArtifact> result = new ArrayList<JpsArtifact>();
    for (JpsArtifact artifact : artifacts) {
        if (artifact.getArtifactType() instanceof AndroidApplicationArtifactType && context.getScope().isAffected(new ArtifactBuildTarget(artifact))) {
            result.add(artifact);
        }
    }
    return result;
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) ArtifactBuildTarget(org.jetbrains.jps.incremental.artifacts.ArtifactBuildTarget) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testOverwriteFileByArchive.

public void testOverwriteFileByArchive() {
    final String xFile = createFile("x.txt", "1");
    final String jarFile = createFile("lib/junit.jar", "123");
    JpsArtifact a = addArtifact(root().archive("junit.jar").fileCopy(xFile).end().parentDirCopy(jarFile));
    buildAll();
    assertOutput(a, fs().archive("junit.jar").file("x.txt", "1"));
    buildAllAndAssertUpToDate();
    change(xFile, "2");
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/junit.jar", "x.txt");
    assertOutput(a, fs().archive("junit.jar").file("x.txt", "2"));
    buildAllAndAssertUpToDate();
    change(jarFile, "321");
    buildAllAndAssertUpToDate();
    delete(jarFile);
    buildAllAndAssertUpToDate();
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 8 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testOverwriteArchiveByFile.

public void testOverwriteArchiveByFile() {
    final String xFile = createFile("d/x.txt", "1");
    final String jarFile = createFile("lib/jdom.jar", "123");
    JpsArtifact a = addArtifact(root().parentDirCopy(jarFile).archive("jdom.jar").parentDirCopy(xFile));
    buildAll();
    assertOutput(a, fs().file("jdom.jar", "123"));
    buildAllAndAssertUpToDate();
    change(xFile, "2");
    buildAllAndAssertUpToDate();
    change(jarFile, "321");
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/jdom.jar", "lib/jdom.jar");
    assertOutput(a, fs().file("jdom.jar", "321"));
    buildAllAndAssertUpToDate();
    delete(xFile);
    buildAllAndAssertUpToDate();
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 9 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testOverwriteExtractedFileByCopied.

public void testOverwriteExtractedFileByCopied() {
    String file = createFile("x.txt", "1");
    String jar = createArchive("x.jar", "x.txt", "2");
    JpsArtifact a = addArtifact(root().fileCopy(file).extractedDir(jar, ""));
    buildAll();
    assertOutput(a, fs().file("x.txt", "1"));
    buildAllAndAssertUpToDate();
    delete(jar);
    createArchive("x.jar", "x.txt", "3");
    buildAll();
    assertOutput(a, fs().file("x.txt", "1"));
    delete(file);
    buildAll();
    assertOutput(a, fs().file("x.txt", "3"));
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Example 10 with JpsArtifact

use of org.jetbrains.jps.model.artifact.JpsArtifact in project intellij-community by JetBrains.

the class ArtifactBuilderOverwriteTest method testOverwriteNestedArchive.

public void testOverwriteNestedArchive() {
    final String cFile = createFile("c.txt", "c");
    final String eFile = createFile("e.txt", "e");
    final JpsArtifact a = addArtifact(root().archive("a.jar").archive("b.jar").fileCopy(cFile).end().end().archive("a.jar").archive("d.jar").fileCopy(eFile));
    buildAll();
    assertOutput(a, fs().archive("a.jar").archive("b.jar").file("c.txt", "c"));
    buildAllAndAssertUpToDate();
    change(eFile, "e2");
    buildAllAndAssertUpToDate();
    change(cFile, "c2");
    buildAll();
    assertDeletedAndCopied("out/artifacts/a/a.jar", "c.txt");
    assertOutput(a, fs().archive("a.jar").archive("b.jar").file("c.txt", "c2"));
    buildAllAndAssertUpToDate();
    delete(eFile);
    buildAllAndAssertUpToDate();
}
Also used : JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact)

Aggregations

JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)85 File (java.io.File)10 JpsModule (org.jetbrains.jps.model.module.JpsModule)10 JarFile (java.util.jar.JarFile)4 ZipFile (java.util.zip.ZipFile)4 IOException (java.io.IOException)3 NotNull (org.jetbrains.annotations.NotNull)3 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)3 JpsCompositePackagingElement (org.jetbrains.jps.model.artifact.elements.JpsCompositePackagingElement)3 THashSet (gnu.trove.THashSet)2 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)2 JpsElement (org.jetbrains.jps.model.JpsElement)2 JpsPackagingElement (org.jetbrains.jps.model.artifact.elements.JpsPackagingElement)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 BuildFileProperty (com.intellij.lang.ant.config.impl.BuildFileProperty)1 SmartList (com.intellij.util.SmartList)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 MultiMap (com.intellij.util.containers.MultiMap)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1