Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对导出过程做了一点改动 #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ idea导出增量补丁插件
把`patcher.jar`下载到`.IntelliJIDEAx0\config\plugins`目录,重启`Idea`,右击即可看到。
[原文](http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/deploying_plugin.html)

1、src的文件或文件夹导出时,直接导出对应的编译好的classes下的类
2、其他的文件或文件夹导出时与在项目中的目录一致
3、WEB-INFO/classes下的文件导出报错时,在moudle属性设置里把classes文件夹的Excluded属性去掉

操作如下:
![](patcher.gif)
Binary file modified patcher.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/PatcherDialog.form
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
</grid>
</constraints>
<properties>
<text value="web"/>
<text value="WebRoot"/>
</properties>
</component>
</children>
Expand Down
21 changes: 15 additions & 6 deletions src/PatcherDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,34 @@ private void onOK() {
String compilerOutputUrl = instance.getCompilerOutputPath().getPath();
// JavaWeb项目的WebRoot目录
String webPath = "/" + webTextField.getText() + "/";
//项目模块的路径E:\git\moudlea\
String modulePath = module.getModuleFilePath().split(".idea/")[0];
// 导出目录
String exportPath = textField.getText() + webPath;
for (int i = 0; i < model.getSize(); i++) {
VirtualFile element = model.getElementAt(i);
String elementName = element.getName();
String elementPath = element.getPath();
if (elementName.endsWith(".java")) {
if(elementPath.contains("/src/")){

//获取到src下的文件名或者目录名,如果是java文件则文件名由.java替换为.class并到编译路径下取,如果是文件夹则直接去编译路径下的文件夹
String className = File.separator + elementPath.split("/src/")[1].replace(".java", ".class");
File from = new File(compilerOutputUrl + className);
File to = new File(exportPath + "WEB-INF" + File.separator + "classes" + className);
FileUtil.copy(from, to);
} else {
FileUtil.copyFileOrDir(from, to);
}else {
File from = new File(elementPath);
File to = new File(exportPath + elementPath.split(webPath)[1]);
FileUtil.copy(from, to);
File to = null;
if(elementPath.contains(webPath)){
to = new File(exportPath + elementPath.split(webPath)[1]);
}else{
to = new File(textField.getText()+ File.separator+ elementPath.substring(modulePath.length()));
}
FileUtil.copyFileOrDir(from, to);
}
}
} catch (Exception e) {
Messages.showErrorDialog(this, "Create Patcher Error!", "Error");
Messages.showErrorDialog(this, "Create Patcher Error!"+e.getMessage(), "Error");
e.printStackTrace();
}

Expand Down