Java Code Examples for org.gradle.api.plugins.ExtraPropertiesExtension#set()

The following examples show how to use org.gradle.api.plugins.ExtraPropertiesExtension#set() . 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: 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 3
Source File: GradleDependencyResolutionHelper.java    From thorntail with Apache License 2.0 6 votes vote down vote up
/**
 * Get data (identified by the given key) that has been cached on the given Gradle project reference.
 *
 * @param project  the Gradle project reference.
 * @param key      the key used for caching the data.
 * @param supplier the function that needs to be executed in the event of a cache-miss.
 * @param <T>      the type of the data stored on the project.
 * @return data that has been cached on the given Gradle project reference.
 */
@SuppressWarnings("unchecked")
private static <T> T getCachedReference(Project project, String key, Supplier<T> supplier) {
    if (project == null) {
        throw new IllegalArgumentException("Gradle project reference cannot be null.");
    }

    Project rootProject = project.getRootProject();
    ExtraPropertiesExtension ext = rootProject.getExtensions().getExtraProperties();
    T value;
    if (ext.has(key)) {
        value = (T) ext.get(key);
    } else {
        value = supplier.get();
        ext.set(key, value);
    }
    return value;
}
 
Example 4
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 5
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 6
Source File: JSassExtension.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Inject
public JSassExtension(ObjectFactory objectFactory) {
    indent = objectFactory.property(String.class);
    indent.convention("  ");

    linefeed = objectFactory.property(String.class);
    linefeed.convention(System.lineSeparator());

    omitSourceMapUrl = objectFactory.property(Boolean.class);
    omitSourceMapUrl.convention(false);

    outputStyle = objectFactory.property(OutputStyle.class);
    outputStyle.convention(OutputStyle.NESTED);

    precision = objectFactory.property(Integer.class);
    precision.convention(8);

    sourceComments = objectFactory.property(Boolean.class);
    sourceComments.convention(false);

    sourceMapContents = objectFactory.property(Boolean.class);
    sourceMapContents.convention(false);

    sourceMapEmbed = objectFactory.property(Boolean.class);
    sourceMapEmbed.convention(false);

    sourceMapEnabled = objectFactory.property(Boolean.class);
    sourceMapEnabled.convention(true);

    ExtraPropertiesExtension extraProperties = new DslObject(this).getExtensions().getExtraProperties();
    for (OutputStyle value : OutputStyle.values()) {
        extraProperties.set(value.name(), value);
    }
}
 
Example 7
Source File: SassCompile.java    From gradle-plugins with MIT License 5 votes vote down vote up
public SassCompile() {
    include("**/*.scss");
    include("**/*.sass");

    ExtraPropertiesExtension extraProperties = new DslObject(this).getExtensions().getExtraProperties();
    for (OutputStyle value : OutputStyle.values()) {
        extraProperties.set(value.name(), value);
    }
}
 
Example 8
Source File: JSassExtension.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Inject
public JSassExtension(ObjectFactory objectFactory) {
    indent = objectFactory.property(String.class);
    indent.convention("  ");

    linefeed = objectFactory.property(String.class);
    linefeed.convention(System.lineSeparator());

    omitSourceMapUrl = objectFactory.property(Boolean.class);
    omitSourceMapUrl.convention(false);

    outputStyle = objectFactory.property(OutputStyle.class);
    outputStyle.convention(OutputStyle.NESTED);

    precision = objectFactory.property(Integer.class);
    precision.convention(8);

    sourceComments = objectFactory.property(Boolean.class);
    sourceComments.convention(false);

    sourceMapContents = objectFactory.property(Boolean.class);
    sourceMapContents.convention(false);

    sourceMapEmbed = objectFactory.property(Boolean.class);
    sourceMapEmbed.convention(false);

    sourceMapEnabled = objectFactory.property(Boolean.class);
    sourceMapEnabled.convention(true);

    ExtraPropertiesExtension extraProperties = new DslObject(this).getExtensions().getExtraProperties();
    for (OutputStyle value : OutputStyle.values()) {
        extraProperties.set(value.name(), value);
    }
}
 
Example 9
Source File: SassCompile.java    From gradle-plugins with MIT License 5 votes vote down vote up
public SassCompile() {
    include("**/*.scss");
    include("**/*.sass");

    ExtraPropertiesExtension extraProperties = new DslObject(this).getExtensions().getExtraProperties();
    for (OutputStyle value : OutputStyle.values()) {
        extraProperties.set(value.name(), value);
    }
}
 
Example 10
Source File: DownloadTaskPlugin.java    From gradle-download-task with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    project.getExtensions().create("download", DownloadExtension.class, project);
    if (project.getExtensions().findByName("verifyChecksum") == null) {
        project.getExtensions().create("verifyChecksum", VerifyExtension.class, project);
    }

    //register top-level properties 'Download' and 'Verify' for our tasks
    ExtraPropertiesExtension extraProperties =
            project.getExtensions().getExtraProperties();
    extraProperties.set(Download.class.getSimpleName(), Download.class);
    extraProperties.set(Verify.class.getSimpleName(), Verify.class);
}
 
Example 11
Source File: CredentialsPlugin.java    From gradle-credentials-plugin with Apache License 2.0 4 votes vote down vote up
private void setProperty(String key, Object value, ExtensionAware extensionAware) {
    ExtraPropertiesExtension properties = extensionAware.getExtensions().getExtraProperties();
    properties.set(key, value);
}