java构建工作空间_java – 我的eclipse插件创建了无限的工作空间构建循环,可能与工作相关...

问题是,由于Juno这个插件在工作空间构建过程中创建了无限循环.

它首先开始缩小我根本没有改变的文件.此文件在构建中创建无限循环.当它完成minifing文件时,它会启动一个新的工作区构建并再次缩小文件,依此类推.

但是经过一段时间后,这种情况会变得更糟,尤其是在新的日食开始时.突然间,有十几个文件缩小了我从未接触过的文件.

如果我卸载我的插件,那么让eclipse构建工作区,重新安装我的插件再次工作.但过了一会儿,这一切都开始了.

我认为这与我处理创建文件的工作方式有关,见下文.也许朱诺的情况发生了变化?但我没有找到任何相关信息.

Job compileJob = new Job("Compile .min.js") {

public IStatus run(IProgressMonitor monitor) {

public IStatus run(IProgressMonitor monitor) {

byte[] bytes = null;

try {

bytes = CallCompiler.compile(fullLocation.toString(), CallCompiler.SIMPLE_OPTIMIZATION).getBytes();

InputStream source = new ByteArrayInputStream(bytes);

if (!newFile.exists()) {

newFile.create(source, IResource.NONE, null);

} else {

newFile.setContents(source, IResource.NONE, null);

}

} catch (IOException e) {

e.printStackTrace();

} catch (CoreException e) {

e.printStackTrace();

}

return Status.OK_STATUS;

}

};

compileJob.setRule(newFile.getProject());

compileJob.schedule();

解决方法:

您需要将newFile设置为派生.派生文件是在构建期间由工作空间隐式创建的文件,并且应该在清理期间擦除它(因为它可以在下一次构建期间恢复).

您可以在IResource上调用setDerived方法:

org.eclipse.core.resources.IResource.setDerived(boolean, IProgressMonitor)

或者在创建文件时,可以将其创建为派生文件,但是这样调用:

newFile.create(stream,IResource.DERIVED,monitor);

但是,您无法通过setContents设置DERIVED标志,在这种情况下您必须显式调用setDerived(true).

来自文档:

A derived resource is a regular file or folder that is

created in the course of translating, compiling, copying, or otherwise

processing other files. Derived resources are not original data, and can be

recreated from other resources. It is commonplace to exclude derived

resources from version and configuration management because they would

otherwise clutter the team repository with version of these ever-changing

files as each user regenerates them.

标签:java,eclipse,build,eclipse-plugin,workspace

来源: https://codeday.me/bug/20190703/1370358.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值