All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jdroid.gradle.java.JavaWebAppGradleExtension.groovy Maven / Gradle / Ivy

There is a newer version: 2.4.0
Show newest version
package com.jdroid.gradle.java

import org.gradle.api.Project

public class JavaWebAppGradleExtension extends JavaGradleExtension {

	public JavaWebAppGradleExtension(Project project) {
		super(project)
	}

	public void setBuildConfigString(def out, String key) {
		setBuildConfigString(out, key, null)
	}

	public void setBuildConfigString(def out, String key, String defaultValue) {
		String constant = "		public static final String " + key + " = ";

		String value = propertyResolver.getStringProp(key, defaultValue)
		if (value == null) {
			constant += "null"
		} else {
			constant += '\"' + value + '\"'
		}

		constant += ";"
		out.writeLine(constant)
	}

	public void setBuildConfigBoolean(def out, String key) {
		setBuildConfigBoolean(out, key, null)
	}

	public void setBuildConfigBoolean(def out, String key, Boolean defaultValue) {
		String constant = "		public static final Boolean " + key + " = ";

		Boolean value = propertyResolver.getBooleanProp(key, defaultValue)
		if (value == null) {
			constant += "null"
		} else {
			constant += value
		}

		constant += ";"
		out.writeLine(constant)
	}

	public void setBuildConfigInteger(def out, String key) {
		setBuildConfigInteger(out, key, null)
	}

	public void setBuildConfigInteger(def out, String key, Integer defaultValue) {
		String constant = "		public static final Integer " + key + " = ";

		Integer value = propertyResolver.getIntegerProp(key, defaultValue)
		if (value == null) {
			constant += "null"
		} else {
			constant += value
		}

		constant += ";"
		out.writeLine(constant)
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy