Java Code Examples for org.gradle.util.GUtil#loadProperties()

The following examples show how to use org.gradle.util.GUtil#loadProperties() . 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: DefaultPersistentDirectoryCache.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public boolean requiresInitialization(FileLock lock) {
    if (!didRebuild) {
        if (validator!=null && !validator.isValid()) {
            LOGGER.debug("Invalidating {} as cache validator return false.", this);
            return true;
        }
    }

    if (!lock.getUnlockedCleanly()) {
        LOGGER.debug("Invalidating {} as it was not closed cleanly.", this);
        return true;
    }

    Properties currentProperties = GUtil.loadProperties(propertiesFile);
    for (Map.Entry<?, ?> entry : properties.entrySet()) {
        if (!entry.getValue().toString().equals(currentProperties.getProperty(entry.getKey().toString()))) {
            LOGGER.debug("Invalidating {} as cache property {} has changed value.", this, entry.getKey());
            return true;
        }
    }
    return false;
}
 
Example 2
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 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()) {
        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 4
Source File: DefaultPersistentDirectoryCache.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public boolean requiresInitialization(FileLock lock) {
    if (!didRebuild) {
        if (validator!=null && !validator.isValid()) {
            LOGGER.debug("Invalidating {} as cache validator return false.", this);
            return true;
        }
    }

    if (!lock.getUnlockedCleanly()) {
        LOGGER.debug("Invalidating {} as it was not closed cleanly.", this);
        return true;
    }

    Properties currentProperties = GUtil.loadProperties(propertiesFile);
    for (Map.Entry<?, ?> entry : properties.entrySet()) {
        if (!entry.getValue().toString().equals(currentProperties.getProperty(entry.getKey().toString()))) {
            LOGGER.debug("Invalidating {} as cache property {} has changed value.", this, entry.getKey());
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: DefaultPersistentDirectoryCache.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public boolean requiresInitialization(FileLock lock) {
    if (!didRebuild) {
        if (cacheUsage == CacheUsage.REBUILD) {
            LOGGER.debug("Invalidating {} as cache usage is set to rebuild.", this);
            return true;
        }
        if (validator!=null && !validator.isValid()) {
            LOGGER.debug("Invalidating {} as cache validator return false.", this);
            return true;
        }
    }

    if (!lock.getUnlockedCleanly()) {
        LOGGER.debug("Invalidating {} as it was not closed cleanly.", this);
        return true;
    }

    Properties currentProperties = GUtil.loadProperties(propertiesFile);
    for (Map.Entry<?, ?> entry : properties.entrySet()) {
        if (!entry.getValue().toString().equals(currentProperties.getProperty(entry.getKey().toString()))) {
            LOGGER.debug("Invalidating {} as cache property {} has changed value.", this, entry.getKey());
            return true;
        }
    }
    return false;
}
 
Example 6
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 7
Source File: DefaultModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Properties loadModuleProperties(String name, File jarFile) {
    try {
        ZipFile zipFile = new ZipFile(jarFile);
        try {
            ZipEntry entry = zipFile.getEntry(String.format("%s-classpath.properties", name));
            return GUtil.loadProperties(zipFile.getInputStream(entry));
        } finally {
            zipFile.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 8
Source File: DefaultGradlePropertiesLoader.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addGradleProperties(Map<String, String> target, File... files) {
    for (File propertyFile : files) {
        if (propertyFile.isFile()) {
            Properties properties = GUtil.loadProperties(propertyFile);
            target.putAll(new HashMap(properties));
        }
    }
}
 
Example 9
Source File: DefaultGradlePropertiesLoader.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addGradleProperties(Map<String, String> target, File... files) {
    for (File propertyFile : files) {
        if (propertyFile.isFile()) {
            Properties properties = GUtil.loadProperties(propertyFile);
            target.putAll(new HashMap(properties));
        }
    }
}
 
Example 10
Source File: DefaultModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Properties loadModuleProperties(String name, File jarFile) {
    try {
        ZipFile zipFile = new ZipFile(jarFile);
        try {
            ZipEntry entry = zipFile.getEntry(String.format("%s-classpath.properties", name));
            return GUtil.loadProperties(zipFile.getInputStream(entry));
        } finally {
            zipFile.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 11
Source File: DefaultGradlePropertiesLoader.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addGradleProperties(Map<String, String> target, File... files) {
    for (File propertyFile : files) {
        if (propertyFile.isFile()) {
            Properties properties = GUtil.loadProperties(propertyFile);
            target.putAll(new HashMap(properties));
        }
    }
}
 
Example 12
Source File: DefaultModuleRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Properties loadModuleProperties(String name, File jarFile) {
    try {
        ZipFile zipFile = new ZipFile(jarFile);
        try {
            ZipEntry entry = zipFile.getEntry(String.format("%s-classpath.properties", name));
            return GUtil.loadProperties(zipFile.getInputStream(entry));
        } finally {
            zipFile.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 13
Source File: DefaultGradlePropertiesLoader.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void addGradleProperties(Map<String, String> target, File... files) {
    for (File propertyFile : files) {
        if (propertyFile.isFile()) {
            Properties properties = GUtil.loadProperties(propertyFile);
            target.putAll(new HashMap(properties));
        }
    }
}
 
Example 14
Source File: DefaultModuleRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Properties loadModuleProperties(String name, File jarFile) {
    try {
        ZipFile zipFile = new ZipFile(jarFile);
        try {
            ZipEntry entry = zipFile.getEntry(String.format("%s-classpath.properties", name));
            return GUtil.loadProperties(zipFile.getInputStream(entry));
        } finally {
            zipFile.close();
        }
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
Example 15
Source File: DefaultPluginModuleRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Properties loadPluginProperties() {
    return GUtil.loadProperties(getClass().getResource("/gradle-plugins.properties"));
}
 
Example 16
Source File: PluginDescriptor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getImplementationClassName() {
    Properties properties = GUtil.loadProperties(propertiesFileUrl);
    return properties.getProperty("implementation-class");
}
 
Example 17
Source File: DefaultPluginModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Properties loadPluginProperties() {
    return GUtil.loadProperties(getClass().getResource("/gradle-plugins.properties"));
}
 
Example 18
Source File: DefaultPluginModuleRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Properties loadPluginProperties() {
    return GUtil.loadProperties(getClass().getResource("/gradle-plugins.properties"));
}
 
Example 19
Source File: PluginDescriptor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getImplementationClassName() {
    Properties properties = GUtil.loadProperties(propertiesFileUrl);
    return properties.getProperty("implementation-class");
}
 
Example 20
Source File: PluginDescriptor.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public String getImplementationClassName() {
    Properties properties = GUtil.loadProperties(propertiesFileUrl);
    return properties.getProperty("implementation-class");
}