|
| 1 | +package com.xwintop.xJavaFxTool.javafx; |
| 2 | + |
| 3 | +public class PluginProgectPomBuildTool { |
| 4 | + public static String getPom_xml(String projectName) { |
| 5 | + return "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + |
| 6 | + "\txsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">\n" + |
| 7 | + "\t<modelVersion>4.0.0</modelVersion>\n" + |
| 8 | + "\n" + |
| 9 | + "\t<groupId>com.xwintop</groupId>\n" + |
| 10 | + "\t<artifactId>x-"+projectName+"</artifactId>\n" + |
| 11 | + "\t<version>0.0.1</version>\n" + |
| 12 | + "\t<packaging>jar</packaging>\n" + |
| 13 | + "\t<name>x-" + projectName + "</name>\n" + |
| 14 | + "\n" + |
| 15 | + "\t<properties>\n" + |
| 16 | + "\t\t<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" + |
| 17 | + "\t</properties>\n" + |
| 18 | + "\n" + |
| 19 | + "\t<repositories>\n" + |
| 20 | + "\t\t<repository>\n" + |
| 21 | + "\t\t\t<id>aliyunmaven</id>\n" + |
| 22 | + "\t\t\t<url>http://maven.aliyun.com/nexus/content/groups/public/</url>\n" + |
| 23 | + "\t\t</repository>\n" + |
| 24 | + "\t\t<repository>\n" + |
| 25 | + "\t\t\t<id>xwintop-maven</id>\n" + |
| 26 | + "\t\t\t<url>https://xwintop.gitee.io/maven/repository</url>\n" + |
| 27 | + "\t\t</repository>\n" + |
| 28 | + "\t\t<repository>\n" + |
| 29 | + "\t\t\t<id>spring-snapshots</id>\n" + |
| 30 | + "\t\t\t<url>http://repo.spring.io/snapshot</url>\n" + |
| 31 | + "\t\t\t<snapshots>\n" + |
| 32 | + "\t\t\t\t<enabled>true</enabled>\n" + |
| 33 | + "\t\t\t</snapshots>\n" + |
| 34 | + "\t\t</repository>\n" + |
| 35 | + "\t\t<repository>\n" + |
| 36 | + "\t\t\t<id>spring-milestones</id>\n" + |
| 37 | + "\t\t\t<url>http://repo.spring.io/milestone</url>\n" + |
| 38 | + "\t\t</repository>\n" + |
| 39 | + "\t</repositories>\n" + |
| 40 | + "\n" + |
| 41 | + "\t<dependencies>\n" + |
| 42 | + "\t\t<dependency>\n" + |
| 43 | + "\t\t\t<groupId>junit</groupId>\n" + |
| 44 | + "\t\t\t<artifactId>junit</artifactId>\n" + |
| 45 | + "\t\t\t<version>4.12</version>\n" + |
| 46 | + "\t\t\t<scope>test</scope>\n" + |
| 47 | + "\t\t</dependency>\n" + |
| 48 | + "\t\t<dependency>\n" + |
| 49 | + "\t\t\t<groupId>com.xwintop</groupId>\n" + |
| 50 | + "\t\t\t<artifactId>xcore</artifactId>\n" + |
| 51 | + "\t\t\t<version>0.0.2-SNAPSHOT</version>\n" + |
| 52 | + "\t\t\t<scope>provided</scope>\n" + |
| 53 | + "\t\t</dependency>\n" + |
| 54 | + "\n" + |
| 55 | + "\t</dependencies>\n" + |
| 56 | + "\t\n" + |
| 57 | + "\t<build>\n" + |
| 58 | + "\t\t<plugins>\n" + |
| 59 | + "\t\t\t<plugin>\n" + |
| 60 | + "\t\t\t\t<groupId>org.apache.maven.plugins</groupId>\n" + |
| 61 | + "\t\t\t\t<artifactId>maven-assembly-plugin</artifactId>\n" + |
| 62 | + "\t\t\t\t<version>2.5.5</version>\n" + |
| 63 | + "\t\t\t\t<configuration>\n" + |
| 64 | + "\t\t\t\t\t<appendAssemblyId>false</appendAssemblyId>\n" + |
| 65 | + "\t\t\t\t\t<encoding>utf-8</encoding>\n" + |
| 66 | + "<!--\t\t\t\t\t<archive>-->\n" + |
| 67 | + "<!--\t\t\t\t\t\t<manifest>-->\n" + |
| 68 | + "<!--\t\t\t\t\t\t\t<mainClass>com.xwintop.xJavaFxTool.Main</mainClass>-->\n" + |
| 69 | + "<!--\t\t\t\t\t\t</manifest>-->\n" + |
| 70 | + "<!--\t\t\t\t\t</archive>-->\n" + |
| 71 | + "\t\t\t\t\t<descriptorRefs>\n" + |
| 72 | + "\t\t\t\t\t\t<descriptorRef>jar-with-dependencies</descriptorRef>\n" + |
| 73 | + "\t\t\t\t\t</descriptorRefs>\n" + |
| 74 | + "\t\t\t\t</configuration>\n" + |
| 75 | + "\t\t\t\t<executions>\n" + |
| 76 | + "\t\t\t\t\t<execution>\n" + |
| 77 | + "\t\t\t\t\t\t<id>make-assembly</id>\n" + |
| 78 | + "\t\t\t\t\t\t<phase>package</phase>\n" + |
| 79 | + "\t\t\t\t\t\t<goals>\n" + |
| 80 | + "\t\t\t\t\t\t\t<goal>single</goal>\n" + |
| 81 | + "\t\t\t\t\t\t</goals>\n" + |
| 82 | + "\t\t\t\t\t</execution>\n" + |
| 83 | + "\t\t\t\t</executions>\n" + |
| 84 | + "\t\t\t</plugin>\n" + |
| 85 | + "\t\t</plugins>\n" + |
| 86 | + "\t</build>\n" + |
| 87 | + "</project>\n"; |
| 88 | + } |
| 89 | + |
| 90 | + public static String getGitignore(String projectName) { |
| 91 | + return "# Default ignored files\n" + |
| 92 | + "#/.gitignore\n" + |
| 93 | + "/x-" + projectName + ".iml\n" + |
| 94 | + "/log/\n" + |
| 95 | + "/target/"; |
| 96 | + } |
| 97 | + |
| 98 | + public static String getMain_java(String projectName, String xmlPath) { |
| 99 | + return "package com.xwintop.xJavaFxTool;\n" + |
| 100 | + "\n" + |
| 101 | + "import javafx.application.Application;\n" + |
| 102 | + "import javafx.event.EventHandler;\n" + |
| 103 | + "import javafx.fxml.FXMLLoader;\n" + |
| 104 | + "import javafx.scene.Parent;\n" + |
| 105 | + "import javafx.scene.Scene;\n" + |
| 106 | + "import javafx.stage.Stage;\n" + |
| 107 | + "import javafx.stage.WindowEvent;\n" + |
| 108 | + "import lombok.extern.slf4j.Slf4j;\n" + |
| 109 | + "\n" + |
| 110 | + "import java.net.URL;\n" + |
| 111 | + "import java.util.ResourceBundle;\n" + |
| 112 | + "\n" + |
| 113 | + "@Slf4j\n" + |
| 114 | + "public class Main extends Application {\n" + |
| 115 | + " public static void main(String[] args) {\n" + |
| 116 | + " try {\n" + |
| 117 | + " launch(args);\n" + |
| 118 | + " } catch (Exception e) {\n" + |
| 119 | + " e.printStackTrace();\n" + |
| 120 | + " }\n" + |
| 121 | + " }\n" + |
| 122 | + "\n" + |
| 123 | + " @Override\n" + |
| 124 | + " public void start(Stage primaryStage) throws Exception {\n" + |
| 125 | + " FXMLLoader fXMLLoader = Main.getFXMLLoader();\n" + |
| 126 | + " ResourceBundle resourceBundle = fXMLLoader.getResources();\n" + |
| 127 | + " Parent root = fXMLLoader.load();\n" + |
| 128 | + " primaryStage.setResizable(true);\n" + |
| 129 | + " primaryStage.setTitle(resourceBundle.getString(\"Title\"));\n" + |
| 130 | + "// primaryStage.getIcons().add(new Image(\"/images/icon.jpg\"));\n" + |
| 131 | + " primaryStage.setScene(new Scene(root));\n" + |
| 132 | + " primaryStage.show();\n" + |
| 133 | + " primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {\n" + |
| 134 | + " @Override\n" + |
| 135 | + " public void handle(WindowEvent event) {\n" + |
| 136 | + " System.exit(0);\n" + |
| 137 | + " }\n" + |
| 138 | + " });\n" + |
| 139 | + " }\n" + |
| 140 | + "\n" + |
| 141 | + " public static FXMLLoader getFXMLLoader() {\n" + |
| 142 | + " ResourceBundle resourceBundle = ResourceBundle.getBundle(\"locale." + projectName + "\");\n" + |
| 143 | + " URL url = Object.class.getResource(\"/com/xwintop/xJavaFxTool/fxmlView/" + xmlPath + "/" + projectName + ".fxml\");\n" + |
| 144 | + " FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle);\n" + |
| 145 | + " return fXMLLoader;\n" + |
| 146 | + " }\n" + |
| 147 | + "}"; |
| 148 | + } |
| 149 | + |
| 150 | + public static String getToolFxmlLoaderConfiguration_xml(String projectName, String xmlPath) { |
| 151 | + return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
| 152 | + "<root>\n" + |
| 153 | + "\t<ToolFxmlLoaderConfiguration title=\"" + xmlPath + "\" menuId=\"p-" + xmlPath + "\" menuParentId=\"moreToolsMenu\" isMenu=\"true\" />\n" + |
| 154 | + "\t<ToolFxmlLoaderConfiguration>\n" + |
| 155 | + "\t\t<url>/com/xwintop/xJavaFxTool/fxmlView/" + xmlPath + "/" + projectName + ".fxml</url>\n" + |
| 156 | + "\t\t<resourceBundleName>locale." + projectName + "</resourceBundleName>\n" + |
| 157 | + "\t\t<className></className>\n" + |
| 158 | + "\t\t<title>Title</title>\n" + |
| 159 | + "\t\t<isDefaultShow></isDefaultShow>\n" + |
| 160 | + "\t\t<menuId></menuId>\n" + |
| 161 | + "\t\t<menuParentId>p-" + xmlPath + "</menuParentId>\n" + |
| 162 | + "\t\t<controllerType>Node</controllerType>\n" + |
| 163 | + "\t</ToolFxmlLoaderConfiguration>\n" + |
| 164 | + "</root>"; |
| 165 | + } |
| 166 | + |
| 167 | + public static String getLocal_properties(String projectName) { |
| 168 | + return "# Dorian.properties是默认的\"Dorian\"资源束文件。 \n" + |
| 169 | + "# 作为中国人,我用自己的地区作为默认 \n" + |
| 170 | + "Title=" + projectName; |
| 171 | + } |
| 172 | + |
| 173 | + public static String getLocal_en_US_properties(String projectName) { |
| 174 | + return "# 文件Dorian_en_US.properties,是美国地区的资源束 \n" + |
| 175 | + "# 它覆盖了默认资源束 \n" + |
| 176 | + "Title=" + projectName; |
| 177 | + } |
| 178 | +} |
0 commit comments