Skip to content

Commit

Permalink
feat: 打包为jar包
Browse files Browse the repository at this point in the history
  • Loading branch information
yagol2020 committed Nov 17, 2021
1 parent f5755fa commit 59c9d36
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 257 deletions.
15 changes: 15 additions & 0 deletions .run/MainGui.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="MainGui" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="gui.designer.MainGui" />
<module name="PaperWebCrawler" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="gui.designer.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
</dependency>



<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -162,6 +161,22 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</testResource>
</testResources>
</build>


Expand Down
81 changes: 0 additions & 81 deletions src/main/java/gui/designer/HelpGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,85 +74,4 @@ public void show() {
frame.setVisible(true);
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
mainPanel.setPreferredSize(new Dimension(500, 300));
helpPanel = new JPanel();
helpPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(helpPanel, gbc);
helpTextArea = new JTextArea();
helpPanel.add(helpTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(panel1, gbc);
final JLabel label1 = new JLabel();
label1.setText("关于");
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
aboutPanel = new JPanel();
aboutPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(aboutPanel, gbc);
aboutTextArea = new JTextArea();
aboutPanel.add(aboutTextArea, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
mainPanel.add(panel2, gbc);
final JLabel label2 = new JLabel();
label2.setText("帮助");
panel2.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
closeButton = new JButton();
closeButton.setText("关闭");
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainPanel.add(closeButton, gbc);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return mainPanel;
}
}
87 changes: 0 additions & 87 deletions src/main/java/gui/designer/MainGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,91 +118,4 @@ public static void main(String[] args) {
private JCheckBox saveResult2Csv;
private JScrollPane logScrollPane;

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
main = new JPanel();
main.setLayout(new GridBagLayout());
main.setPreferredSize(new Dimension(900, 500));
titleLabel = new JLabel();
titleLabel.setText("Paper Web Crawler 文献网站爬虫工具");
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
main.add(titleLabel, gbc);
authorLabel = new JLabel();
authorLabel.setText("作者:@yagol, @vencerk");
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
main.add(authorLabel, gbc);
content = new JPanel();
content.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.BOTH;
main.add(content, gbc);
searchQueryInput = new JTextField();
content.add(searchQueryInput, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
content.add(panel1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
panel1.add(panel2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
searchButton = new JButton();
searchButton.setText("开始");
panel2.add(searchButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
saveResult2Csv = new JCheckBox();
saveResult2Csv.setSelected(true);
saveResult2Csv.setText("是否保存到csv");
panel2.add(saveResult2Csv, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
panel1.add(panel3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
helpButton = new JButton();
helpButton.setText("关于帮助");
helpButton.setMnemonic('帮');
helpButton.setDisplayedMnemonicIndex(2);
panel3.add(helpButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
searchQueryLabel = new JLabel();
searchQueryLabel.setText("关键字");
content.add(searchQueryLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
logScrollPane = new JScrollPane();
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
main.add(logScrollPane, gbc);
logArea = new JTextArea();
logArea.setEditable(false);
logArea.setLineWrap(true);
logScrollPane.setViewportView(logArea);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return main;
}
}
52 changes: 0 additions & 52 deletions src/main/java/gui/designer/PaperInfoGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,56 +80,4 @@ private void createUIComponents() {
paperInfoTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
paperInfo = new JPanel();
paperInfo.setLayout(new GridBagLayout());
paperInfo.setPreferredSize(new Dimension(900, 800));
paperInfo.setVisible(true);
upperPanel = new JPanel();
upperPanel.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
GridBagConstraints gbc;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.fill = GridBagConstraints.BOTH;
paperInfo.add(upperPanel, gbc);
searchLabel = new JLabel();
searchLabel.setText("查询的关键字是:");
upperPanel.add(searchLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
searchInputLabel = new JLabel();
searchInputLabel.setText("Label");
upperPanel.add(searchInputLabel, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
jScrollPane = new JScrollPane();
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
paperInfo.add(jScrollPane, gbc);
jScrollPane.setViewportView(paperInfoTable);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return paperInfo;
}
}
3 changes: 3 additions & 0 deletions src/main/java/gui/param/GuiParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
* @Description
**/
public class GuiParam {
/**
* 回车的code
*/
public final static int ENTER_CODE = 10;
}
4 changes: 3 additions & 1 deletion src/main/java/param/NormalParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
* @Description
**/
public class NormalParam {
public final static String BASE_RESOURCES_PATH = NormalParam.class.getResource("/").getPath();
public final static String ORDINAL_WORD_TH = "th";
public final static String APOSTROPHE = "'";
public final static String TRANSACTIONS = "Transaction";
public final static Pattern NUMBER_PATTERN = Pattern.compile("[0-9]+");
public final static String HELP_FILE_PATH = "help.txt";
public final static String HELP_FILE_PATH = "/gui_text_file/help.txt";
/**
* 小、中、大括号内容匹配,注意需要循环遍历
*/
Expand All @@ -30,4 +31,5 @@ public static List<String> getBracketContentList(String input) {
}
return result;
}

}
2 changes: 1 addition & 1 deletion src/main/java/util/ChromeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
**/
public class ChromeUtil {
static final String CHROME_DRIVER_PROPERTY = "webdriver.chrome.driver";
static final String CHROME_DRIVER_PATH = "src/main/resources/chromedriver";
static final String CHROME_DRIVER_PATH = "chromedriver";
static ChromeOptions CHROME_OPTIONS;

public ChromeUtil() {
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/util/MyFileUtil.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package util;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.csv.CsvUtil;
import cn.hutool.core.text.csv.CsvWriter;
import cn.hutool.core.util.CharsetUtil;

import java.io.InputStream;
import java.util.List;

/**
Expand All @@ -21,6 +22,11 @@ public static void writeMultiLine2Csv(String filePath, String[] header, List<Str
}

public static String readFile(String path) {
return FileUtil.readString(path, CharsetUtil.CHARSET_UTF_8);
InputStream inputStream = MyFileUtil.class.getResourceAsStream(path);
return IoUtil.read(inputStream, CharsetUtil.CHARSET_UTF_8);
}

public static String getResourcesFilePath(String filePathInResources) {
return MyFileUtil.class.getResource(filePathInResources).getPath();
}
}
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/test/java/BastTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import param.IeeeParam;
import param.NormalParam;
import result.BaseResult;
import result.IeeeResult;
import util.ChromeUtil;
Expand Down Expand Up @@ -74,4 +75,9 @@ public void testIeeePaperIdXpath() {
});
webDriver.quit();
}

@Test
public void testResourcesPath() {
System.out.println(NormalParam.BASE_RESOURCES_PATH);
}
}
Loading

0 comments on commit 59c9d36

Please sign in to comment.