Java 格拉德尔+;AspectJ日志跟踪正在尝试在“;仪器仪表&x201D;失败

Java 格拉德尔+;AspectJ日志跟踪正在尝试在“;仪器仪表&x201D;失败,java,gradle,aspectj,gradle-plugin,aspectj-maven-plugin,Java,Gradle,Aspectj,Gradle Plugin,Aspectj Maven Plugin,编辑: [error] Syntax error, insert "|| Expression" to complete Expression [ant:iajc] String str = (before) ? "before" : "after" ; [ant:iajc] 我在这里推出了虚拟源代码 它似乎在编译AspectJinstrumentation的同时也在编译 但是,我在插装过程中收到警告 [

编辑:

[error] Syntax error, insert "|| Expression" to complete Expression
[ant:iajc] String str = (before) ? "before" : "after" ;
[ant:iajc]               

我在这里推出了虚拟源代码

它似乎在编译AspectJ
instrumentation
的同时也在编译

但是,我在
插装过程中收到警告

[ant:iajc] [warning] build config error: skipping missing, empty or
 corrupt aspectpath entry: 
/Users/swapnil.kotwal/Downloads/basic-demo/my-demo/src/com/my/demo/TracingAspect.java
有人能帮我解决这个
TracingAspect.java
问题吗

我的蚂蚁目标如下所示。。我已将其转换为Gradle构建脚本,如下一步
代码块所示

<target name="weave-aspects" depends="compile, jar-common" unless="weave.suppressed"
          description="weaves the AspectJ's aspects into classes compiled by compile target">
    <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
      <classpath>
        <pathelement location="${abcd.proj.base}/lib/aspectj-1.9.4/aspectjtools-1.9.4.jar" />
      </classpath>
    </taskdef>

    <echo message="Weaving the AspectJ's aspects into class files ..." />

    <iajc inpath="${classes}" destdir="${classes}"
          debug="true" fork="true"
          maxmem="${iajc.memoryLimit}"
          source="${javaVersion}">
    <!-- path of jar containing TracingAspect -->
    <aspectpath>
       <path>
         <fileset dir="${pqr.bundle.image}" includes="pqr-bundle-common*.jar" />
       </path>
    </aspectpath>
    <classpath>
       <pathelement path="${deps}" />
       <pathelement path="${abcd.proj.base}/lib/aspectj-1.9.4/aspectjrt-1.9.4.jar" />
      </classpath>
    </iajc>
  </target>

TracingAspect.java
如下所示。此类是
aspectpath
jar的一部分

    <aspectpath>
       <path>
         <fileset dir="${pqr.bundle.image}" includes="pqr-bundle-common*.jar" />
       </path>
    </aspectpath>
其中
接口:-my.common.logging.Untraced
为空(目前)

但是,由于存在随机编译错误,它在
检测过程中失败

(注意:如果没有aspectJ我的编译,jar创建将正常进行。)

通常,AspectJ应该进行日志跟踪编织,但它试图再次编译它,因此失败了。有线索知道我在这里遗漏了什么吗

它失败的Java代码如下所示:

private static void runRule(boolean before) {
    String str = (before) ? "before" : "after" ;
}
错误为:

[error] Syntax error, insert "|| Expression" to complete Expression
[ant:iajc] String str = (before) ? "before" : "after" ;
[ant:iajc]               

我在这里推出了工作示例演示代码

我还能够在
插装期间解决我的业务项目问题,问题在于代码的图片下面

private static void runRule(boolean before) {
    String str = (before) ? "before" : "after" ;
}
基本上,AspectJ不喜欢
布尔值周围的圆括号,在
之前,我更改了代码,AspectJ开始正常工作

private static void runRule(boolean before) {
    String str = before ? "before" : "after" ;
}

我添加了
TracingAspect.java
class。。其他多模块项目都有业务逻辑,我担心我可能会在这里发表文章。我不能提供细节,因为它很敏感。我对纯
gradle
实现很满意,但没有为这些插件提供任何适当的文档我在这里推了虚拟源代码,它正在正确编译并尝试添加跟踪(
TracingAspect.java
有一些问题,我正在处理)感谢您的GitHub项目,我可以看到,在调用Ant任务时,您试图使用
*.java
源文件的路径作为方面路径,而不是包含
*.class
文件或
*.jar
库的目录。我认为这显然不起作用。但我仍然认为你应该使用Gradle插件。顺便说一句,我可以帮助你更好地与Maven,我不说Gradle。但如果她克隆了你的项目并帮助你修复它,其他人可能会这样做。我的实现不完全在
Gradle
中,但它已经解除了我的阻碍(目前最为有效),如果你能帮助我和社区获得纯Gradle实现。。。请继续回答。谢谢你在说什么<代码>运行规则
甚至不存在于您的存储库中。您还遇到了一系列其他错误,包括配置错误
aspectPath:“$projectDir/my demo/src/com/my/demo/TracingAspect.java”,
。我拉了你最后的提交,甚至无法将项目导入Gradle。其他Gradle项目在我的机器上构建良好。那么这个问题是如何解决的呢?您发布了一个已损坏的项目。请提取最新代码。你不应该面对任何问题。如果你读了我最后的评论,我明确提到我面临一些问题,但我正在努力解决。我认为您只需要提取最新的代码。演示项目唯一的问题是我没有更改
TracingAspect.java
文件以合并虚拟代码
日志跟踪
,但目前我无法为此投入时间。我会在某个愉快的时候做这件事。我的业务问题解决了,这对我来说是最重要的。正如我所说,即使在你让我这么做之前,我也确实提取了最新的代码。Gradle守护进程未启动,无论是在命令行(Windows cmd或Git Bash)上还是在IntelliJ IDEA中。我刚刚又拉了一次,但自从上次尝试以来没有新的提交。在您的存储库中仍然没有
runRule
,我放弃了Gradle,只是尝试编译您在另一个AspectJ项目中遇到问题的Java方法。我可以重现这个问题,并相信它是AspectJ编译器中的一个解析错误。所以我为它创建了一个。所以这不是关于从Ant到Gradle的迁移,而是关于AspectJ编译。同样的情况也会发生在你以前的Ant项目中。您最初错误地将编译器Ant任务配置为源文件名,这只是另一个模糊这一点的问题。
private static void runRule(boolean before) {
    String str = (before) ? "before" : "after" ;
}
private static void runRule(boolean before) {
    String str = before ? "before" : "after" ;
}