Search in sources :

Example 1 with BuildFileProperty

use of com.intellij.lang.ant.config.impl.BuildFileProperty 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 2 with BuildFileProperty

use of com.intellij.lang.ant.config.impl.BuildFileProperty in project intellij-community by JetBrains.

the class AntArtifactProperties method getAllProperties.

public List<BuildFileProperty> getAllProperties(@NotNull Artifact artifact) {
    final List<BuildFileProperty> properties = new ArrayList<>();
    properties.add(new BuildFileProperty(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, artifact.getOutputPath()));
    properties.addAll(myExtensionProperties.myUserProperties);
    return properties;
}
Also used : BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) ArrayList(java.util.ArrayList)

Example 3 with BuildFileProperty

use of com.intellij.lang.ant.config.impl.BuildFileProperty in project intellij-community by JetBrains.

the class AntArtifactPropertiesEditor method reset.

public void reset() {
    myRunTargetCheckBox.setSelected(myProperties.isEnabled());
    myTarget = myProperties.findTarget(AntConfiguration.getInstance(myContext.getProject()));
    final List<BuildFileProperty> properties = new ArrayList<>();
    for (BuildFileProperty property : myProperties.getAllProperties(myContext.getArtifact())) {
        properties.add(new BuildFileProperty(property.getPropertyName(), property.getPropertyValue()));
    }
    myContainer = new SinglePropertyContainer<>(ANT_PROPERTIES, properties);
    myBinding.loadValues(myContainer);
    updatePanel();
}
Also used : BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) ArrayList(java.util.ArrayList)

Example 4 with BuildFileProperty

use of com.intellij.lang.ant.config.impl.BuildFileProperty in project intellij-community by JetBrains.

the class JpsAntArtifactExtensionImpl method getAntProperties.

@Override
public List<BuildFileProperty> getAntProperties() {
    final List<BuildFileProperty> properties = new ArrayList<>();
    properties.add(new BuildFileProperty(ARTIFACT_OUTPUT_PATH_PROPERTY, getArtifact().getOutputPath()));
    properties.addAll(myProperties.myUserProperties);
    return properties;
}
Also used : BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) ArrayList(java.util.ArrayList)

Example 5 with BuildFileProperty

use of com.intellij.lang.ant.config.impl.BuildFileProperty in project intellij-community by JetBrains.

the class JpsAntSerializationTest method testLoadArtifactProperties.

public void testLoadArtifactProperties() {
    loadProject(PROJECT_PATH);
    List<JpsArtifact> artifacts = JpsArtifactService.getInstance().getSortedArtifacts(myProject);
    assertEquals(2, artifacts.size());
    JpsArtifact dir = artifacts.get(0);
    assertEquals("dir", dir.getName());
    JpsAntArtifactExtension preprocessing = JpsAntExtensionService.getPreprocessingExtension(dir);
    assertNotNull(preprocessing);
    assertTrue(preprocessing.isEnabled());
    assertEquals(getUrl("build.xml"), preprocessing.getFileUrl());
    assertEquals("show-message", preprocessing.getTargetName());
    assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, assertOneElement(preprocessing.getAntProperties()).getPropertyName());
    JpsAntArtifactExtension postprocessing = JpsAntExtensionService.getPostprocessingExtension(dir);
    assertNotNull(postprocessing);
    assertEquals(getUrl("build.xml"), postprocessing.getFileUrl());
    assertEquals("create-file", postprocessing.getTargetName());
    List<BuildFileProperty> properties = postprocessing.getAntProperties();
    assertEquals(2, properties.size());
    assertEquals(JpsAntArtifactExtensionImpl.ARTIFACT_OUTPUT_PATH_PROPERTY, properties.get(0).getPropertyName());
    assertEquals(dir.getOutputPath(), properties.get(0).getPropertyValue());
    assertEquals("message.text", properties.get(1).getPropertyName());
    assertEquals("post", properties.get(1).getPropertyValue());
    JpsArtifact jar = artifacts.get(1);
    assertEquals("jar", jar.getName());
    assertNull(JpsAntExtensionService.getPostprocessingExtension(jar));
    assertNull(JpsAntExtensionService.getPreprocessingExtension(jar));
}
Also used : BuildFileProperty(com.intellij.lang.ant.config.impl.BuildFileProperty) JpsArtifact(org.jetbrains.jps.model.artifact.JpsArtifact) JpsAntArtifactExtension(org.jetbrains.jps.ant.model.artifacts.JpsAntArtifactExtension)

Aggregations

BuildFileProperty (com.intellij.lang.ant.config.impl.BuildFileProperty)8 ArrayList (java.util.ArrayList)3 Property (com.intellij.compiler.ant.taskdefs.Property)1 AntBuildTarget (com.intellij.lang.ant.config.AntBuildTarget)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 SimpleDataContext (com.intellij.openapi.actionSystem.impl.SimpleDataContext)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArtifactPropertiesProvider (com.intellij.packaging.artifacts.ArtifactPropertiesProvider)1 File (java.io.File)1 JpsAntBuildFileOptions (org.jetbrains.jps.ant.model.JpsAntBuildFileOptions)1 JpsAntInstallation (org.jetbrains.jps.ant.model.JpsAntInstallation)1 JpsAntArtifactExtension (org.jetbrains.jps.ant.model.artifacts.JpsAntArtifactExtension)1 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)1