Search in sources :

Example 1 with ArtifactPropertiesProvider

use of com.intellij.packaging.artifacts.ArtifactPropertiesProvider 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)

Aggregations

Property (com.intellij.compiler.ant.taskdefs.Property)1 BuildFileProperty (com.intellij.lang.ant.config.impl.BuildFileProperty)1 ArtifactPropertiesProvider (com.intellij.packaging.artifacts.ArtifactPropertiesProvider)1