在gradle

时间:2016-02-12 16:41:58

标签: java gradle ant keystore key-generator

目前我正在使用ant XML来生成密钥和签名jar。

我希望将来通过将所有内容转换为Gradle任务而不使用ant.importBuild而不必使用keytool -genkey手动创建密钥来消除XML。我相信我已经找到了签名部分,但需要帮助处理gradle中的密钥生成。

在ant XML中,它目前看起来像这样:

<genkey alias="${key.alias}" keystore="${keystore.location}" storepass="${keystore.password}" dname="CN=name, OU=IT, O=org, C=US"/>

是否有相同的任务来生成内置于gradle中的键?除非我遗漏了某些内容,否则Gradle似乎总是认为已经生成了密钥。

我已经阅读了这些antsigning plugin页面,但也许我看不到森林,因为我迷失在树林里。

谢谢。

2 个答案:

答案 0 :(得分:4)

Gradle treats Ant as a 'First Class Citizen'.

You can invoke any common Ant task in Gradle simply by prefixing the task name with ant. Properties are set similar to parameters to a method call. For more information see this link: https://docs.gradle.org/current/userguide/ant.html

So, for your case it would look something like:

$("#icon-menu-mobile").click(function() {
    var effect = 'slide';
    var options = 'left';
    var duration = 500;

    $('#panel').toggle(effect, options, duration);
});

$("#exit").click(function() {
    var effect = 'slide';
    var options = 'right';
    var duration = 500;

    $('#panel').toggle(effect, options, duration);
});

答案 1 :(得分:1)

Here is an answer to your secondary question. Easier with a concrete example.

build.xml:

.SOC-columns img {
    margin-left: auto;
    margin-right: auto;
}

build.gradle:

<project name="TestProject" default="test" basedir=".">
  <property name="key.alias" value="keyaliasvalue"/>

  <target name="testtarget">
      <echo>Test Target</echo>
  </target>
</project>

Results of running: gradle test

ant.importBuild 'build.xml'

task test << {
    println("Value of ants key.alias property: " + ant.properties['key.alias'])
}

Notes:

1) For my test case I place both the ant build.xml and build.gradle in the same directory.

2) Notice I use the format:

D:\Data\test>gradle test
:test
Value of ants key.alias property: keyaliasvalue

BUILD SUCCESSFUL

Total time: 2.787 secs

If there was not a period (.) in the property name it would be easier. Because the Gradle script is an actually Groovy file, the (.) causes Groovy to think you are trying to access a nested property on an object. Without the (.) in the name, like 'keyalias', you could simplify the syntax to:

ant.properties['key.alias'].