gpt4 book ai didi

android - 使用Java代码的Gradle自定义任务

转载 作者:行者123 更新时间:2023-12-03 06:23:51 25 4
gpt4 key购买 nike

我正在使用Gradle,并且需要在编译阶段进行一些预处理。我的预处理器是来自外部库(从Maven Central加载的依赖项)中的类。我怎么写这样的task

我有这样的代码:

  buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
classpath group: 'com.googlecode.htmlcompressor', name: 'htmlcompressor', version: '1.4'
}
}
task compressXML {
logging.captureStandardOutput LogLevel.INFO
String xml = file('assets/menu.xml').text;
XmlCompressor compressor = new XmlCompressor();
String compressedXml = compressor.compress(xml);
println compressedXml;
}

但是Gradle看不到 XmlCompressor类的问题:
build.gradle': 70: unable to resolve class XmlCompressor 
@ line 70, column 27.
XmlCompressor compressor = new XmlCompressor();
^

build file '../build.gradle': 70: unable to resolve class XmlCompressor
@ line 70, column 40.
XmlCompressor compressor = new XmlCompressor();
^

2 errors

最佳答案

如果您使用JCP preprocessor,则可以访问其页面,并且有wiki page how to make preprocessing with gradle for android projects

关于android - 使用Java代码的Gradle自定义任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19130743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com