Search in sources :

Example 1 with Property

use of com.intellij.compiler.ant.taskdefs.Property in project intellij-community by JetBrains.

the class JavaFxChunkBuildExtension method generateTasksForArtifact.

@Override
public void generateTasksForArtifact(Artifact artifact, boolean preprocessing, ArtifactAntGenerationContext context, CompositeGenerator generator) {
    if (preprocessing)
        return;
    if (!(artifact.getArtifactType() instanceof JavaFxApplicationArtifactType))
        return;
    final CompositePackagingElement<?> rootElement = artifact.getRootElement();
    final List<PackagingElement<?>> children = new ArrayList<>();
    String artifactFileName = rootElement.getName();
    for (PackagingElement<?> child : rootElement.getChildren()) {
        if (child instanceof ArchivePackagingElement) {
            artifactFileName = ((ArchivePackagingElement) child).getArchiveFileName();
            children.addAll(((ArchivePackagingElement) child).getChildren());
        } else {
            children.add(child);
        }
    }
    final String artifactName = FileUtil.getNameWithoutExtension(artifactFileName);
    final String tempDirPath = BuildProperties.propertyRef(context.createNewTempFileProperty("artifact.temp.output." + artifactName, artifactFileName));
    final PackagingElementResolvingContext resolvingContext = ArtifactManager.getInstance(context.getProject()).getResolvingContext();
    for (Generator childGenerator : computeChildrenGenerators(resolvingContext, new DirectoryAntCopyInstructionCreator(tempDirPath), context, artifact.getArtifactType(), children)) {
        generator.add(childGenerator);
    }
    final JavaFxArtifactProperties properties = (JavaFxArtifactProperties) artifact.getProperties(JavaFxArtifactPropertiesProvider.getInstance());
    final JavaFxArtifactProperties.JavaFxPackager javaFxPackager = new JavaFxArtifactProperties.JavaFxPackager(artifact, properties, context.getProject()) {

        @Override
        protected void registerJavaFxPackagerError(String message) {
        }
    };
    final String tempDirDeployPath = tempDirPath + "/deploy";
    final List<JavaFxAntGenerator.SimpleTag> tags = JavaFxAntGenerator.createJarAndDeployTasks(javaFxPackager, artifactFileName, artifact.getName(), tempDirPath, tempDirDeployPath, context.getProject().getBasePath());
    for (JavaFxAntGenerator.SimpleTag tag : tags) {
        buildTags(generator, tag);
    }
    if (properties.isEnabledSigning()) {
        final boolean selfSigning = properties.isSelfSigning();
        String vendor = properties.getVendor();
        if (vendor != null) {
            vendor = vendor.replaceAll(",", "\\\\,");
        }
        generator.add(new Property(artifactBasedProperty(ARTIFACT_VENDOR_SIGN_PROPERTY, artifactName), "CN=" + vendor));
        final String alias = selfSigning ? "jb" : properties.getAlias();
        generator.add(new Property(artifactBasedProperty(ARTIFACT_ALIAS_SIGN_PROPERTY, artifactName), alias));
        final String keystore = selfSigning ? tempDirPath + File.separator + "jb-key.jks" : properties.getKeystore();
        generator.add(new Property(artifactBasedProperty(ARTIFACT_KEYSTORE_SIGN_PROPERTY, artifactName), keystore));
        final String storepass = selfSigning ? "storepass" : new String(Base64.getDecoder().decode(properties.getStorepass()), StandardCharsets.UTF_8);
        generator.add(new Property(artifactBasedProperty(ARTIFACT_STOREPASS_SIGN_PROPERTY, artifactName), storepass));
        final String keypass = selfSigning ? "keypass" : new String(Base64.getDecoder().decode(properties.getKeypass()), StandardCharsets.UTF_8);
        generator.add(new Property(artifactBasedProperty(ARTIFACTKEYPASS_SIGN_PROPERTY, artifactName), keypass));
        final Pair[] keysDescriptions = createKeysDescriptions(artifactName);
        if (selfSigning) {
            generator.add(new Tag("genkey", ArrayUtil.prepend(Couple.of("dname", BuildProperties.propertyRef(artifactBasedProperty(ARTIFACT_VENDOR_SIGN_PROPERTY, artifactName))), keysDescriptions)));
        }
        final Tag signjar = new Tag("signjar", keysDescriptions);
        final Tag fileset = new Tag("fileset", Couple.of("dir", tempDirDeployPath));
        fileset.add(new Tag("include", Couple.of("name", "*.jar")));
        signjar.add(fileset);
        generator.add(signjar);
    }
    final DirectoryAntCopyInstructionCreator creator = new DirectoryAntCopyInstructionCreator(BuildProperties.propertyRef(context.getConfiguredArtifactOutputProperty(artifact)));
    generator.add(creator.createDirectoryContentCopyInstruction(tempDirDeployPath));
    final Tag deleteTag = new Tag("delete", Couple.of("includeemptydirs", "true"));
    deleteTag.add(new Tag("fileset", Couple.of("dir", tempDirPath)));
    generator.add(deleteTag);
}
Also used : JavaFxApplicationArtifactType(org.jetbrains.plugins.javaFX.packaging.JavaFxApplicationArtifactType) ArrayList(java.util.ArrayList) ArchivePackagingElement(com.intellij.packaging.impl.elements.ArchivePackagingElement) JavaFxArtifactProperties(org.jetbrains.plugins.javaFX.packaging.JavaFxArtifactProperties) JavaFxAntGenerator(org.jetbrains.plugins.javaFX.packaging.JavaFxAntGenerator) DirectoryAntCopyInstructionCreator(com.intellij.compiler.ant.artifacts.DirectoryAntCopyInstructionCreator) ArchivePackagingElement(com.intellij.packaging.impl.elements.ArchivePackagingElement) Property(com.intellij.compiler.ant.taskdefs.Property) JavaFxAntGenerator(org.jetbrains.plugins.javaFX.packaging.JavaFxAntGenerator) Pair(com.intellij.openapi.util.Pair)

Example 2 with Property

use of com.intellij.compiler.ant.taskdefs.Property in project intellij-community by JetBrains.

the class ArtifactAntGenerationContextImpl method createNewTempFileProperty.

public String createNewTempFileProperty(String basePropertyName, String fileName) {
    String tempFileName = fileName;
    int i = 1;
    String tempSubdir = null;
    while (myTempFileNames.contains(tempFileName)) {
        tempSubdir = String.valueOf(i++);
        tempFileName = tempSubdir + "/" + fileName;
    }
    String propertyName = basePropertyName;
    i = 2;
    while (myProperties.contains(propertyName)) {
        propertyName = basePropertyName + i++;
    }
    runBeforeBuild(new Property(propertyName, BuildProperties.propertyRelativePath(ARTIFACTS_TEMP_DIR_PROPERTY, tempFileName)));
    if (tempSubdir != null && myCreatedTempSubdirs.add(tempSubdir)) {
        runBeforeBuild(new Mkdir(BuildProperties.propertyRelativePath(ARTIFACTS_TEMP_DIR_PROPERTY, tempSubdir)));
    }
    myTempFileNames.add(tempFileName);
    myProperties.add(propertyName);
    return propertyName;
}
Also used : Mkdir(com.intellij.compiler.ant.taskdefs.Mkdir) Property(com.intellij.compiler.ant.taskdefs.Property)

Example 3 with Property

use of com.intellij.compiler.ant.taskdefs.Property in project intellij-community by JetBrains.

the class AntArtifactBuildExtension method generateTasksForArtifact.

@Override
public void generateTasksForArtifact(Artifact artifact, boolean preprocessing, ArtifactAntGenerationContext context, CompositeGenerator generator) {
    final ArtifactPropertiesProvider provider;
    if (preprocessing) {
        provider = AntArtifactPreProcessingPropertiesProvider.getInstance();
    } else {
        provider = AntArtifactPostprocessingPropertiesProvider.getInstance();
    }
    final AntArtifactProperties properties = (AntArtifactProperties) artifact.getProperties(provider);
    if (properties != null && properties.isEnabled()) {
        final String path = VfsUtil.urlToPath(properties.getFileUrl());
        String fileName = PathUtil.getFileName(path);
        String dirPath = PathUtil.getParentPath(path);
        final String relativePath = GenerationUtils.toRelativePath(dirPath, BuildProperties.getProjectBaseDir(context.getProject()), BuildProperties.getProjectBaseDirProperty(), context.getGenerationOptions());
        final Tag ant = new Tag("ant", Pair.create("antfile", fileName), Pair.create("target", properties.getTargetName()), Pair.create("dir", relativePath));
        final String outputPath = BuildProperties.propertyRef(context.getArtifactOutputProperty(artifact));
        ant.add(new Property(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, outputPath));
        for (BuildFileProperty property : properties.getUserProperties()) {
            ant.add(new Property(property.getPropertyName(), property.getPropertyValue()));
        }
        generator.add(ant);
    }
}
Also used : BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) Property(com.intellij.compiler.ant.taskdefs.Property) ArtifactPropertiesProvider(com.intellij.packaging.artifacts.ArtifactPropertiesProvider)

Example 4 with Property

use of com.intellij.compiler.ant.taskdefs.Property in project intellij-community by JetBrains.

the class ChunkBuildPluginExtension method process.

public void process(Project project, ModuleChunk chunk, GenerationOptions genOptions, CompositeGenerator generator) {
    final Module[] modules = chunk.getModules();
    if (isPlugins(modules)) {
        final BuildTargetsFactory factory = BuildTargetsFactory.getInstance();
        final Module module = modules[0];
        PluginBuildConfiguration buildProperties = PluginBuildConfiguration.getInstance(module);
        final Set<Library> libs = new HashSet<>();
        PluginBuildUtil.getLibraries(module, libs);
        @NonNls String jarPath = chunk.getBaseDir().getPath() + "/" + chunk.getName();
        if (libs.isEmpty()) {
            jarPath += ".jar";
        } else {
            jarPath += ".zip";
        }
        generator.add(new Property(PluginBuildProperties.getJarPathProperty(chunk.getName()), GenerationUtils.toRelativePath(jarPath, chunk, genOptions)), 1);
        generator.add(factory.createComment(DevKitBundle.message("ant.build.jar.comment", chunk.getName())), 1);
        generator.add(new BuildJarTarget(chunk, genOptions, buildProperties));
    }
}
Also used : NonNls(org.jetbrains.annotations.NonNls) PluginBuildConfiguration(org.jetbrains.idea.devkit.build.PluginBuildConfiguration) Library(com.intellij.openapi.roots.libraries.Library) Module(com.intellij.openapi.module.Module) Property(com.intellij.compiler.ant.taskdefs.Property) HashSet(java.util.HashSet)

Example 5 with Property

use of com.intellij.compiler.ant.taskdefs.Property in project intellij-community by JetBrains.

the class GroovyAntCustomCompilerProvider method generateCustomCompilerTaskRegistration.

/**
   * {@inheritDoc}
   */
@Override
public void generateCustomCompilerTaskRegistration(Project project, GenerationOptions genOptions, CompositeGenerator generator) {
    final GroovyConfigUtils utils = GroovyConfigUtils.getInstance();
    // find SDK library with maximum version number in order to use for compiler
    final Library[] libraries = utils.getAllUsedSDKLibraries(project);
    if (libraries.length == 0) {
        // no SDKs in the project, the task registration is not generated
        return;
    }
    final Collection<String> versions = utils.getSDKVersions(libraries);
    String maxVersion = versions.isEmpty() ? null : Collections.max(versions);
    Library sdkLib = null;
    for (Library lib : libraries) {
        if (maxVersion == null || maxVersion.equals(utils.getSDKVersion(LibrariesUtil.getGroovyLibraryHome(lib)))) {
            sdkLib = lib;
        }
    }
    assert sdkLib != null;
    String groovySdkPathRef = BuildProperties.getLibraryPathId(sdkLib.getName());
    generator.add(new Property(GROOVYC_TASK_SDK_PROPERTY, groovySdkPathRef));
    //noinspection HardCodedStringLiteral
    Tag taskdef = new Tag("taskdef", Couple.of("name", "groovyc"), Couple.of("classname", "org.codehaus.groovy.ant.Groovyc"), Couple.of("classpathref", "${" + GROOVYC_TASK_SDK_PROPERTY + "}"));
    generator.add(taskdef);
}
Also used : GroovyConfigUtils(org.jetbrains.plugins.groovy.config.GroovyConfigUtils) Library(com.intellij.openapi.roots.libraries.Library) Property(com.intellij.compiler.ant.taskdefs.Property)

Aggregations

Property (com.intellij.compiler.ant.taskdefs.Property)5 Library (com.intellij.openapi.roots.libraries.Library)2 DirectoryAntCopyInstructionCreator (com.intellij.compiler.ant.artifacts.DirectoryAntCopyInstructionCreator)1 Mkdir (com.intellij.compiler.ant.taskdefs.Mkdir)1 BuildFileProperty (com.intellij.lang.ant.config.impl.BuildFileProperty)1 Module (com.intellij.openapi.module.Module)1 Pair (com.intellij.openapi.util.Pair)1 ArtifactPropertiesProvider (com.intellij.packaging.artifacts.ArtifactPropertiesProvider)1 ArchivePackagingElement (com.intellij.packaging.impl.elements.ArchivePackagingElement)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NonNls (org.jetbrains.annotations.NonNls)1 PluginBuildConfiguration (org.jetbrains.idea.devkit.build.PluginBuildConfiguration)1 GroovyConfigUtils (org.jetbrains.plugins.groovy.config.GroovyConfigUtils)1 JavaFxAntGenerator (org.jetbrains.plugins.javaFX.packaging.JavaFxAntGenerator)1 JavaFxApplicationArtifactType (org.jetbrains.plugins.javaFX.packaging.JavaFxApplicationArtifactType)1 JavaFxArtifactProperties (org.jetbrains.plugins.javaFX.packaging.JavaFxArtifactProperties)1