Search in sources :

Example 1 with GradleDslLiteral

use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslLiteral in project android by JetBrains.

the class SigningConfigModel method setStoreFile.

public SigningConfigModel setStoreFile(@NotNull String storeFile) {
    if (myDslElement.getPropertyElement(STORE_FILE) == null) {
        GradleDslMethodCall methodCall = new GradleDslMethodCall(myDslElement, "file", STORE_FILE);
        GradleDslLiteral literal = new GradleDslLiteral(methodCall, "");
        literal.setValue(storeFile);
        methodCall.addNewArgument(literal);
        myDslElement.setNewElement(STORE_FILE, methodCall);
    } else {
        GradleDslExpression expression = getStoreFileExpression();
        if (expression != null) {
            expression.setValue(storeFile);
        }
    }
    return this;
}
Also used : GradleDslExpression(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression) GradleDslMethodCall(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall) GradleDslLiteral(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslLiteral)

Example 2 with GradleDslLiteral

use of com.android.tools.idea.gradle.dsl.parser.elements.GradleDslLiteral in project android by JetBrains.

the class SigningConfigModel method setPasswordValue.

private void setPasswordValue(@NotNull String property, @NotNull Type type, @NotNull String text) {
    if (type == PLAIN_TEXT) {
        myDslElement.setNewLiteral(property, text);
        return;
    }
    GradleNullableValue<SigningConfigPassword> passwordValue = getPasswordValue(property);
    SigningConfigPassword password = passwordValue.value();
    if (password != null && password.getType() == type) {
        GradleDslExpression element = getPasswordElement(property);
        if (element != null) {
            element.setValue(text);
            return;
        }
    }
    GradleDslMethodCall methodCall = null;
    if (type == ENVIRONMENT_VARIABLE) {
        methodCall = new GradleDslMethodCall(myDslElement, SYSTEM_GETENV, property);
    } else if (type == CONSOLE_READ) {
        methodCall = new GradleDslMethodCall(myDslElement, SYSTEM_CONSOLE_READ_LINE, property);
    }
    if (methodCall != null) {
        GradleDslLiteral argumentElement = new GradleDslLiteral(methodCall, methodCall.getName());
        argumentElement.setValue(text);
        methodCall.addNewArgument(argumentElement);
        myDslElement.setNewElement(property, methodCall);
    }
}
Also used : GradleDslExpression(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression) GradleDslMethodCall(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall) GradleDslLiteral(com.android.tools.idea.gradle.dsl.parser.elements.GradleDslLiteral)

Aggregations

GradleDslExpression (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslExpression)2 GradleDslLiteral (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslLiteral)2 GradleDslMethodCall (com.android.tools.idea.gradle.dsl.parser.elements.GradleDslMethodCall)2