bash中的javabiginger;重写gradlew

bash中的javabiginger;重写gradlew,java,linux,gradle,Java,Linux,Gradle,我试图重写gradle的包装器,这样它就不依赖于二进制文件。我被迫这样做,因为Apache不允许在源代码中使用二进制文件。我已经完成了大部分工作,但是gradle为发行版生成散列的方式对我来说是有问题的。代码如下 有人知道如何在just bash中重做吗 /** * This method computes a hash of the provided {@code string}. * <p> * The algorithm in use by this method is

我试图重写gradle的包装器,这样它就不依赖于二进制文件。我被迫这样做,因为Apache不允许在源代码中使用二进制文件。我已经完成了大部分工作,但是gradle为发行版生成散列的方式对我来说是有问题的。代码如下

有人知道如何在just bash中重做吗

/**
 * This method computes a hash of the provided {@code string}.
 * <p>
 * The algorithm in use by this method is as follows:
 * <ol>
 *    <li>Compute the MD5 value of {@code string}.</li>
 *    <li>Truncate leading zeros (i.e., treat the MD5 value as a number).</li>
 *    <li>Convert to base 36 (the characters {@code 0-9a-z}).</li>
 * </ol>
 */
private String getHash(String string) {
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        byte[] bytes = string.getBytes();
        messageDigest.update(bytes);
        return new BigInteger(1, messageDigest.digest()).toString(36);
    } catch (Exception e) {
        throw new RuntimeException("Could not hash input string.", e);
    }
}
/**
*此方法计算提供的{@code string}的哈希值。
*
*此方法使用的算法如下所示:
* 
*
  • 计算{@code string}的MD5值
  • *
  • 截断前导零(即,将MD5值视为一个数字)
  • *
  • 转换为基数36(字符{@code 0-9a-z})
  • * */ 私有字符串getHash(字符串字符串){ 试一试{ MessageDigest=MessageDigest.getInstance(“MD5”); byte[]bytes=string.getBytes(); messageDigest.update(字节); 返回新的BigInteger(1,messageDigest.digest()).toString(36); }捕获(例外e){ 抛出新的RuntimeException(“无法散列输入字符串。”,e); } }
    编辑:

    如果我可以在mac/linux上默认的任何其他脚本语言上实现这一点,我也会很好。因此,如果您可以在python中实现这一点,而无需安装软件包,那么也可以

    编辑2:

    现在,我只对URL进行MD5哈希,并用以下脚本替换gradle-wrapper.jar所做的所有逻辑:


    如果我可以在不需要安装东西的情况下替换哈希逻辑来匹配,那就太好了。

    gradlew不是已经开源了吗?它是开源的。问题在于,使用gradle包装器需要一个包含二进制gradle-wrapper.jar的项目。这在Apache中是不允许的;只允许源代码。我们还希望让人们可以轻松地构建它。doing./gradlew应该可以在apache对二进制文件的限制下工作。你确定存在这样的限制吗?从我第一眼看到的地方来看,repo中有二进制文件:@Opal:这不对;包装器是下载其他所有内容的工具
    gradle/wrapper/gradle wrapper.jar
    是包装器的一部分。