Java Code Examples for org.gradle.api.Project#setProperty()

The following examples show how to use org.gradle.api.Project#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectPropertySettingBuildLoader.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }
    
    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        try {
            project.setProperty(entry.getKey(), entry.getValue());
        } catch (MissingPropertyException e) {
            if (!entry.getKey().equals(e.getProperty())) {
                throw e;
            }
            // Ignore and define as an extra property
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
 
Example 2
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example 3
Source File: ProjectPropertySettingBuildLoader.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }
    
    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        if (project.hasProperty(entry.getKey())) {
            project.setProperty(entry.getKey(), entry.getValue());    
        } else {
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
 
Example 4
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example 5
Source File: BasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.maybeCreate(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.maybeCreate(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example 6
Source File: ReleasePlugin.java    From curiostack with MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
  if (project.getParent() != null) {
    throw new IllegalStateException(
        "gradle-release-plugin can only be applied to the root project.");
  }

  if (!project.hasProperty("version") || "unspecified".equals(project.findProperty("version"))) {
    String version = determineVersion(project);
    project.setProperty("version", version);

    project.subprojects(
        proj -> {
          if (!proj.hasProperty("version")
              || "unspecified".equals(proj.findProperty("version"))) {
            proj.setProperty("version", version);
          }
        });

    project.getLogger().quiet("Automatically determined version: " + version);
  }
}
 
Example 7
Source File: ProjectPropertySettingBuildLoader.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }
    
    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        try {
            project.setProperty(entry.getKey(), entry.getValue());
        } catch (MissingPropertyException e) {
            if (!entry.getKey().equals(e.getProperty())) {
                throw e;
            }
            // Ignore and define as an extra property
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
 
Example 8
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}
 
Example 9
Source File: ProjectPropertySettingBuildLoader.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void addPropertiesToProject(Project project) {
    Properties projectProperties = new Properties();
    File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
    LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
    if (projectPropertiesFile.isFile()) {
        projectProperties = GUtil.loadProperties(projectPropertiesFile);
        LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
                projectProperties.keySet());
    } else {
        LOGGER.debug("project property file does not exists. We continue!");
    }
    
    Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
    ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
    for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
        if (project.hasProperty(entry.getKey())) {
            project.setProperty(entry.getKey(), entry.getValue());    
        } else {
            extraProperties.set(entry.getKey(), entry.getValue());
        }
    }
}
 
Example 10
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureConfigurations(final Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    project.setProperty("status", "integration");

    Configuration archivesConfiguration = configurations.create(Dependency.ARCHIVES_CONFIGURATION).
            setDescription("Configuration for archive artifacts.");

    configurations.create(Dependency.DEFAULT_CONFIGURATION).
            setDescription("Configuration for default artifacts.");

    final DefaultArtifactPublicationSet defaultArtifacts = project.getExtensions().create(
            "defaultArtifacts", DefaultArtifactPublicationSet.class, archivesConfiguration.getArtifacts()
    );

    configurations.all(new Action<Configuration>() {
        public void execute(Configuration configuration) {
            configuration.getArtifacts().all(new Action<PublishArtifact>() {
                public void execute(PublishArtifact artifact) {
                    defaultArtifacts.addCandidate(artifact);
                }
            });
        }
    });
}