我在项目中添加了简单的注释驱动方面,而IntelliJ无法编译它:
annotation type patterns are only supported at Java 5 compliance level or above
请建议,在配置编译级别的情况下(在项目设置中,对于整个项目和所有模块,它设置为Java 6),在settings-> aspectj weaver中,只能启用weaver并查看方面列表
UPD 问题与OpenJDK有关,因为aspectJ weaver插件无法正确识别它的版本。该补丁已提交给维护者。
--- src/common/se/expertsystem/intellij/PluginUtils.java.orig 2012-04-11 14:03:35.000000000 +0300
+++ src/common/se/expertsystem/intellij/PluginUtils.java 2012-04-11 14:47:11.000000000 +0300
@@ -31,32 +31,34 @@
*/
package se.expertsystem.intellij;
+import com.intellij.openapi.application.ApplicationInfo;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.roots.OrderRootType;
-import com.intellij.openapi.util.io.FileUtil;
-import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.application.ApplicationInfo;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.roots.OrderRootType;
+import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ActionRunner;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.io.IOException;
import java.io.File;
-import java.lang.reflect.Method;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Class containing useful utility methods for IntelliJ IDEA plugins.
@@ -68,6 +70,8 @@
private static final Class[] NO_PARAMETERS = new Class[] {};
+ private static final Pattern jdkVersionResolver = Pattern.compile("(java|openjdk)\\s+version\\s+\"(\\d+)\\.(\\d+)");
+
/**
* Find classpath for module. Returns list of <code>File</code>s.
* @param project Project to get classpath for.
@@ -296,13 +300,21 @@
*/
public static boolean isJava5(Module module) {
final String versionString = getJdkVersionString(module); // Example: java version "1.5.0_07"
- if(versionString.startsWith("java version \"1.") && versionString.length() > "java version \"1.".length())
- return versionString.charAt("java version \"1.".length()) >= '5';
- LOG.error("Unparsable version string: " + versionString);
- return false;
+ final Matcher versionMatcher = jdkVersionResolver.matcher(versionString);
+ if (!versionMatcher.find()) {
+ LOG.error("Unparsable version string (regex failed): " + versionString);
+ return false;
+ } else if (!("1".equals(versionMatcher.group(2))
+ && versionMatcher.group(3).charAt(0) >= '5')) {
+ LOG.error("Version invalid: major "+versionMatcher.group(2)+
+ " , minor "+versionMatcher.group(3));
+ return false;
+ }
+ LOG.info("Detected JDK: "+versionString);
+ return true;
}
- /////////////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////////////
// Methods for progress indication
/////////////////////////////////////////////////////////////////////////////
@@ -382,4 +394,4 @@
return modules;
}
}
-}
\ No newline at end of file
+}
答案 0 :(得分:1)
尝试
source="1.5"
插入build.xml中的iajc任务
答案 1 :(得分:0)
我通过升级aspectjweaver jar解决了现有的合规性问题。使用aspectjweaver-1.7.3.jar