Ubuntu 22.04.03、运行环境为:jdk1.7 、ant1.8. 、maven 3.8.
所需文件 | 下载地址 |
---|---|
JDK 7/1.7 | jdk-7u80-linux-x64.tar.gz |
Fault-localization-dat | 地址 或者git clone https://bitbucket.org/rjust/fault-localization-data.git |
Defects4j-1.2.0 | defects4j-1.2.0 |
Defects4j-repos | defects4j-repo |
注意,根据自己实际下载的目录进行更改即可
tar -zxvf jdk-7u281-linux-x64.tar.gz
# 配置JDK环境变量
sudo vim /etc/profile
export JAVA_HOME=/home/ubuntu/jdk1.7.0_281
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
# 安装各工具
sudo apt-get install subversion
sudo apt-get install cpanminus
# 注意maven的版本必须要跟jdk1.7匹配
sudo apt-get install maven
unzip rjust-fault-localization-data.zip && mv rjust-fault-localization-data fault-localization
# 【/home/ubuntu/fault-localization】
tar -zxvf defects4j-1.2.0.tar.gz && mv defects4j-1.2.0 defects4j
# 【/home/ubuntu/fault-localization/defects4j】
cpanm --installdeps .
######################################
# requires 'DBI', '>= 1.63'; #
# requires 'DBD::CSV', '>= 0.48'; #
# requires 'URI', '>= 1.72'; #
# requires 'JSON', '>= 2.97'; #
# requires 'JSON::Parse', '>= 0.55'; #
# requires 'List::Util', '>= 1.33'; #
######################################
./init.sh
# 如果连外网速度过慢,可以手动初始化:例如repo部分
# 【/home/ubuntu/fault-localization/defects4j/project_repos】
unzip -q -u defects4j-repos.zip && mv defects4j/project_repos/* . && rm -r defects4j
# 环境变量(临时)
export PATH=$PATH:/home/ubuntu/fault-localization/defects4j/framework/bin
# 测试命令
defects4j info -p Lang
# 报错:Can't locate DBI.pm in @INC (you may need to install the DBI module)
tar -zxvf DBI-1.643.tar.gz && cd DBI-1.643/
perl Makefile.PL
make
make test
sudo make install
# 【/home/ubuntu/fault-localization/gzoltar】
git clone https://github.com/GZoltar/gzoltar.git
mv gzoltar gzoltar-repo && cd gzoltar-repo/
# 跳过测试
mvn clean package -DskipTests=true
./setup.sh
# 调整环境变量(不是/etc/profile)
vim ~/.bashrc
1. 在文件最添加下面的内容
export FL_DATA_HOME=/home/ubuntu/fault-localization
export KILLMAP_HOME=$FL_DATA_HOME/killmap
export GZOLTAR_REPO_HOME=$FL_DATA_HOME/gzoltar/gzoltar-repo
export GZOLTAR_CLI_JAR=$GZOLTAR_REPO_HOME/com.gzoltar.cli/target/com.gzoltar.cli-1.7.3-SNAPSHOT-jar-with-dependencies.jar
export GZOLTAR_AGENT_JAR=$GZOLTAR_REPO_HOME/com.gzoltar.agent.rt/target/com.gzoltar.agent.rt-1.7.3-SNAPSHOT-all.jar
export D4J_HOME=$FL_DATA_HOME/defects4j
export DEFECTS4J_HOME=$D4J_HOME
export PATH=$PATH:$D4J_HOME/framework/bin
2. 最后记得运行下面的指令或者直接reboot使环境生效
source ~/.bashrc
注意:代码框架下的setup.sh文件内有多处错误,环境变量GZOLTAR_CLI_JAR和GZOLTAR_AGENT_JAR配置反了,还有"$GZOLTAR_REPO_HOME"总是有地方前面又加上前缀地址,还有配置D4J_HOME环境变量的时候在最后面加上多的/导致后面在Path中与/framework相连时出现问题。建议直接根据上面写的环境变量一一比对后更改
修改 untils.sh 324 行
local relevant_tests_file="$D4J_HOME/framework/projects/$pid/relevant_tests/$bid
修改 job.sh 570行
cp -Rv gzoltars/* "$SCRIPT_DIR/"
最后执行GZoltar的job.sh进行测试
./job.sh --project Math --bug 1 --output_dir Math/1 --tool developer
注意将这一部分替换成下面的,作者在写的时候有些地方多加了$HERE/,但是有些地方又没加,导致文件读取失败
GZOLTAR_REPO_HOME="$HERE/gzoltar/gzoltar-repo"
if [ ! -d "$GZOLTAR_REPO_HOME" ]; then
git clone https://github.com/GZoltar/gzoltar.git "$GZOLTAR_REPO_HOME" || die 'unable to clone GZoltar'
(cd "$GZOLTAR_REPO_HOME" && \
git checkout 7abaeaf6c86ecdfac26e39db6a59c27393f9ef19 && \
mvn clean package -DskipTests)
fi
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom: Received fatal alert: protocol_version -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
产生原因:
此错误表明 Maven 无法从中央 Maven 仓库下载 maven-clean-plugin 插件以及其依赖项的工件描述符。具体错误信息指出了"Received fatal alert: protocol_version",这可能是因为使用的 SSL/TLS 协议版本有问题。
检查网络连接:
确保你正常地上网,可以连接到 Maven 中央仓库(https://repo.maven.apache.org/maven2),你可以试着用网络浏览器打开此 URL。
指定使用的 SSL/TLS 协议版本:
在你的 Maven 设置文件settings.xml中添加以下配置,这段配置会让 Maven 使用 TLS 1.2 协议与 Maven 仓库进行通信,该文件位于MAVEN_HOME/config目录下:
<settings>
<profiles>
<profile>
<id>defaultProfileid>
<activation>
<activeByDefault>trueactiveByDefault>
activation>
<properties>
<maven.wagon.http.ssl.protocols>TLSv1.2maven.wagon.http.ssl.protocols>
properties>
profile>
profiles>
settings>
<localRepository>/usr/local/lib/mvn/apache-maven-3.8.8/repositorylocalRepository>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/repository/publicurl>
<mirrorOf>centralmirrorOf>
mirror>
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
root@ubuntu-virtual-machine:~# api-get -y uninstall ant
Command 'api-get' not found, did you mean:
command 'apt-get' from deb apt (2.4.10)
Try: apt install <deb name>
root@ubuntu-virtual-machine:~# sudo apt-get remove ant
这种情况一般是ant版本过高导致,解决方法如下:
sudo apt-get remove ant
sudo tar -zxvf apache-ant-1.8.3-bin.tar.gz