diff --git a/.gitignore b/.gitignore
index 1bf50a6..82e0ecc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,8 @@
/target/
/download/
/webroot/
-.DS_Store
\ No newline at end of file
+.DS_Store
+.gradle
+build
+local.properties
+classes/
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index eb0fb61..a5ac852 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,60 +1,55 @@
-/*
- * This file was generated by the Gradle 'init' task.
- */
-allprojects {
- group = 'com.fr.plugin'
- version = '10.0'
-}
-subprojects {
- apply plugin: 'java'
- apply plugin: 'maven-publish'
+apply plugin: 'java'
+apply plugin: 'maven-publish'
+
+/**
+ * 可以修改这个变量以依赖不同的开发版本
+ */
+def fineVersion = '10.0-RELEASE-SNAPSHOT'
- repositories {
- mavenLocal()
- maven {
- url = uri('http://mvn.finedevelop.com/repository/maven-public/')
- }
+group = 'com.fr.plugin'
+version = '10.0'
- maven {
- url = uri('http://repo.maven.apache.org/maven2')
- }
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('http://mvn.finedevelop.com/repository/maven-public/')
}
- dependencies {
- implementation 'com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.activator:fine-activator:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.core:fine-core:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.webui:fine-webui:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.datasource:fine-datasource:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.decision:fine-decision:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.decision:fine-decision-report:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.schedule:fine-schedule:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.schedule:fine-schedule-report:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.intelligence:fine-swift:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.intelligence:fine-accumulator:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.report:fine-report-engine:10.0-RELEASE-SNAPSHOT'
- implementation 'com.fr.report:fine-report-designer:10.0-RELEASE-SNAPSHOT'
- implementation 'io.socket:socket.io-client:0.7.0'
- implementation 'org.aspectj:aspectjrt:1.6.9'
- implementation 'org.swingexplorer:swexpl:2.0'
- implementation 'org.swingexplorer:swag:1.0'
- implementation 'org.apache.tomcat:tomcat-catalina:8.5.32'
- implementation 'mysql:mysql-connector-java:5.1.44'
- implementation 'com.fr.third:jxbrowser:6.23.1'
- implementation 'com.fr.third:jxbrowser-mac:6.23.1'
- testImplementation 'junit:junit:4.12'
- testImplementation 'org.easymock:easymock:3.5.1'
+ maven {
+ url = uri('http://repo.maven.apache.org/maven2')
}
+}
- sourceCompatibility = '1.6'
+task install(type: Copy) {
+ into "webroot/WEB-INF/lib"
+ from configurations.runtimeClasspath
+}
- publishing {
- publications {
- maven(MavenPublication) {
- from(components.java)
- }
- }
- }
+dependencies {
+ implementation 'com.fr.third:fine-third:' + fineVersion
+ implementation 'com.fr.activator:fine-activator:' + fineVersion
+ implementation 'com.fr.core:fine-core:' + fineVersion
+ implementation 'com.fr.webui:fine-webui:' + fineVersion
+ implementation 'com.fr.datasource:fine-datasource:' + fineVersion
+ implementation 'com.fr.decision:fine-decision:' + fineVersion
+ implementation 'com.fr.decision:fine-decision-report:' + fineVersion
+ implementation 'com.fr.schedule:fine-schedule:' + fineVersion
+ implementation 'com.fr.schedule:fine-schedule-report:' + fineVersion
+ implementation 'com.fr.intelligence:fine-swift:' + fineVersion
+ implementation 'com.fr.intelligence:fine-accumulator:' + fineVersion
+ implementation 'com.fr.report:fine-report-engine:' + fineVersion
+ implementation 'com.fr.report:fine-report-designer:' + fineVersion
+ implementation 'io.socket:socket.io-client:0.7.0'
+ implementation 'org.aspectj:aspectjrt:1.6.9'
+ implementation 'org.swingexplorer:swexpl:2.0'
+ implementation 'org.swingexplorer:swag:1.0'
+ implementation 'org.apache.tomcat:tomcat-catalina:8.5.32'
+ implementation 'mysql:mysql-connector-java:5.1.44'
+ implementation 'com.fr.third:jxbrowser:6.23.1'
+ implementation 'com.fr.third:jxbrowser-mac:6.23.1'
+ testImplementation 'junit:junit:4.12'
+ testImplementation 'org.easymock:easymock:3.5.1'
}
+sourceCompatibility = '1.8'
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a4b4429..f3d3406 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
+distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/plugin-function/build.gradle b/plugin-function/build.gradle
index 308f0bd..d7f752f 100644
--- a/plugin-function/build.gradle
+++ b/plugin-function/build.gradle
@@ -1,19 +1,41 @@
-/*
- * This file was generated by the Gradle 'init' task.
- */
-//打包直接执行zip命令 Gradle -> Tasks -> other -> zip
-dependencies {
- implementation fileTree(dir: 'lib', include: ['*.jar'])
+import org.codehaus.groovy.runtime.GStringImpl
+
+plugins {
+ id 'java'
+ id 'maven-publish'
+}
+
+ext {
+ /**
+ * 项目中依赖的jar的路径
+ * 1.如果依赖的jar需要打包到zip中,放置在lib根目录下
+ * 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可
+ */
+ libPath = "$projectDir/../webroot/WEB-INF/lib" as GStringImpl
+
+ /**
+ * 是否对插件的class进行加密保护,防止反编译
+ */
+ guard = true
+
+ def pluginInfo = getPluginInfo()
+ pluginPre = "fine-plugin"
+ pluginName = pluginInfo.id
+ pluginVersion = pluginInfo.version
}
-ant.importBuild("ant_build.xml")
+
+group = 'com.fr.plugin'
+version = '10.0'
+sourceCompatibility = '8'
+
+ant.importBuild("encrypt.xml")
//定义ant变量
ant.projectDir = projectDir
ant.references["compile.classpath"] = ant.path {
- fileset(dir: "lib", includes: '*.jar')
- fileset(dir: "$rootDir/webroot/WEB-INF/lib", includes: '*.jar')
+ fileset(dir: libPath, includes: '**/*.jar')
fileset(dir: ".",includes:"**/*.jar" )
}
-//clean -> classes -> copyFiles -> compile_javas(加密) -> preJar -> makeJar->copyFile->zip
+
classes.dependsOn('clean')
task copyFiles(type: Copy,dependsOn: 'classes'){
@@ -22,36 +44,41 @@ task copyFiles(type: Copy,dependsOn: 'classes'){
into "$projectDir/classes"
}
-task preJar(type:Copy,dependsOn: 'compile_javas'){
+task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
from "$projectDir/classes"
into "$buildDir/classes/java/main"
+ include "**/*.class"
doLast(){
delete file("$projectDir/classes")
}
}
+jar.dependsOn("preJar")
task makeJar(type: Jar,dependsOn: preJar){
- from fileTree(dir:"$buildDir/classes/java/main") //包含assets文件
+ from fileTree(dir:"$buildDir/classes/java/main")
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
destinationDir = file("$buildDir/libs")
}
task copyFile(type: Copy,dependsOn: ["makeJar"]){
from "$buildDir/libs"
- from "$projectDir/lib"
+ from("$projectDir/lib") {
+ include "*.jar"
+ }
from "$projectDir/plugin.xml"
- into file("$buildDir/temp/fr-"+"$project.name"+"-$project.version")
+ into file("$buildDir/temp/plugin")
}
task zip(type:Zip,dependsOn:["copyFile"]){
from "$buildDir/temp"
destinationDir file("$buildDir/install")
- //生成的文件名: baseName-appendix-0.0.1.zip
-// baseName 'baseName'
-// appendix 'appendix'
-// version '0.0.1'
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
}
-
//控制build时包含哪些文件,排除哪些文件
processResources {
// exclude everything
@@ -60,3 +87,29 @@ processResources {
// except this file
// include 'xx.xml'
}
+
+/*读取plugin.xml中的version*/
+def getPluginInfo(){
+ def xmlFile = file("plugin.xml")
+ if (!xmlFile.exists()) {
+ return ["id":"none", "version":"1.0.0"]
+ }
+ def plugin = new XmlParser().parse(xmlFile)
+ def version = plugin.version[0].text()
+ def id = plugin.id[0].text()
+ return ["id":id,"version":version]
+}
+
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('http://mvn.finedevelop.com/repository/maven-public/')
+ }
+}
+
+dependencies {
+ //使用本地jar
+ implementation fileTree(dir: 'lib', include: ['**/*.jar'])
+ implementation fileTree(dir: libPath, include: ['**/*.jar'])
+}
+
diff --git a/plugin-function/build.xml b/plugin-function/build.xml
deleted file mode 100644
index 7a6dc84..0000000
--- a/plugin-function/build.xml
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/plugin-function/encrypt.xml b/plugin-function/encrypt.xml
new file mode 100644
index 0000000..1401cd1
--- /dev/null
+++ b/plugin-function/encrypt.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin-function/pom.xml b/plugin-function/pom.xml
deleted file mode 100644
index f45aea2..0000000
--- a/plugin-function/pom.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
- 4.0.0
-
-
- com.fr.plugin
- starter
- 10.0
-
- jar
- plugin-function
-
-
- com.fr.plugin
- gson
- 1.0
- system
- ${project.basedir}/lib/gson-2.3.1.jar
-
-
-
-
- ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.function.test-1.0/classes
-
-
\ No newline at end of file
diff --git a/plugin-function/readme.md b/plugin-function/readme.md
new file mode 100644
index 0000000..a6ffd32
--- /dev/null
+++ b/plugin-function/readme.md
@@ -0,0 +1,3 @@
+# 函数插件
+
+该函数可以对一组数值求绝对值。
\ No newline at end of file
diff --git a/plugin-function2/build.gradle b/plugin-function2/build.gradle
new file mode 100644
index 0000000..fa5238b
--- /dev/null
+++ b/plugin-function2/build.gradle
@@ -0,0 +1,115 @@
+import org.codehaus.groovy.runtime.GStringImpl
+
+plugins {
+ id 'java'
+ id 'maven-publish'
+}
+
+ext {
+ /**
+ * 项目中依赖的jar的路径
+ * 1.如果依赖的jar需要打包到zip中,放置在lib根目录下
+ * 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可
+ */
+ libPath = "$projectDir/../webroot/WEB-INF/lib" as GStringImpl
+
+ /**
+ * 是否对插件的class进行加密保护,防止反编译
+ */
+ guard = false
+
+ def pluginInfo = getPluginInfo()
+ pluginPre = "fine-plugin"
+ pluginName = pluginInfo.id
+ pluginVersion = pluginInfo.version
+}
+
+group = 'com.fr.plugin'
+version = '10.0'
+sourceCompatibility = '8'
+
+ant.importBuild("encrypt.xml")
+//定义ant变量
+ant.projectDir = projectDir
+ant.references["compile.classpath"] = ant.path {
+ fileset(dir: libPath, includes: '**/*.jar')
+ fileset(dir: ".",includes:"**/*.jar" )
+}
+
+classes.dependsOn('clean')
+
+task copyFiles(type: Copy,dependsOn: 'classes'){
+ from "$buildDir/classes/java/main"
+ from "$buildDir/resources/main"
+ into "$projectDir/classes"
+}
+
+task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
+ from "$projectDir/classes"
+ into "$buildDir/classes/java/main"
+ include "**/*.class"
+ doLast(){
+ delete file("$projectDir/classes")
+ }
+}
+jar.dependsOn("preJar")
+
+task makeJar(type: Jar,dependsOn: preJar){
+ from fileTree(dir:"$buildDir/classes/java/main")
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
+ destinationDir = file("$buildDir/libs")
+}
+
+task copyFile(type: Copy,dependsOn: ["makeJar"]){
+ from "$buildDir/libs"
+ from("$projectDir/lib") {
+ include "*.jar"
+ }
+ from "$projectDir/plugin.xml"
+ into file("$buildDir/temp/plugin")
+}
+
+task zip(type:Zip,dependsOn:["copyFile"]){
+ from "$buildDir/temp"
+ destinationDir file("$buildDir/install")
+ baseName pluginPre
+ appendix pluginName
+ version pluginVersion
+}
+
+//控制build时包含哪些文件,排除哪些文件
+processResources {
+// exclude everything
+// 用*.css没效果
+// exclude '**/*.css'
+// except this file
+// include 'xx.xml'
+}
+
+/*读取plugin.xml中的version*/
+def getPluginInfo(){
+ def xmlFile = file("plugin.xml")
+ if (!xmlFile.exists()) {
+ return ["id":"none", "version":"1.0.0"]
+ }
+ def plugin = new XmlParser().parse(xmlFile)
+ def version = plugin.version[0].text()
+ def id = plugin.id[0].text()
+ return ["id":id,"version":version]
+}
+
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('http://mvn.finedevelop.com/repository/maven-public/')
+ }
+}
+
+dependencies {
+ //使用本地jar
+ implementation fileTree(dir: 'lib', include: ['**/*.jar'])
+ implementation fileTree(dir: libPath, include: ['**/*.jar'])
+}
+
diff --git a/plugin-function/ant_build.xml b/plugin-function2/encrypt.xml
similarity index 100%
rename from plugin-function/ant_build.xml
rename to plugin-function2/encrypt.xml
diff --git a/plugin-function2/plugin.xml b/plugin-function2/plugin.xml
new file mode 100644
index 0000000..6fa3dc2
--- /dev/null
+++ b/plugin-function2/plugin.xml
@@ -0,0 +1,17 @@
+
+ com.fr.plugin.function.math
+
+ yes
+ 1.0
+ 10.0
+ 2018-07-31
+ author
+
+
+ ]]>
+
+
+
+
+
\ No newline at end of file
diff --git a/plugin-function2/readme.md b/plugin-function2/readme.md
new file mode 100644
index 0000000..e8bd51f
--- /dev/null
+++ b/plugin-function2/readme.md
@@ -0,0 +1,3 @@
+# 函数插件
+
+该函数可以求两个整数的最大公约数。
\ No newline at end of file
diff --git a/plugin-function2/src/main/java/com/fr/plugin/function/math/MaxCommonDivisor.java b/plugin-function2/src/main/java/com/fr/plugin/function/math/MaxCommonDivisor.java
new file mode 100644
index 0000000..1a55dad
--- /dev/null
+++ b/plugin-function2/src/main/java/com/fr/plugin/function/math/MaxCommonDivisor.java
@@ -0,0 +1,43 @@
+package com.fr.plugin.function.math;
+
+import com.fr.general.GeneralUtils;
+import com.fr.intelli.record.Focus;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.script.AbstractFunction;
+import com.fr.stable.ArrayUtils;
+import com.fr.stable.Primitive;
+import com.fr.stable.exception.FormulaException;
+
+/**
+ * @author richie
+ * @version 10.0
+ * Created by richie on 2020/6/2
+ */
+@EnableMetrics
+public class MaxCommonDivisor extends AbstractFunction {
+
+ @Override
+ @Focus(id="com.fr.plugin.function.math", text="")
+ public Object run(Object[] args) throws FormulaException {
+ int len = ArrayUtils.getLength(args);
+ if (len < 2) {
+ return Primitive.ERROR_VALUE;
+ }
+ int m = GeneralUtils.objectToNumber(args[0]).intValue();
+ int n = GeneralUtils.objectToNumber(args[1]).intValue();
+ return maxCommonDivisor(m, n);
+ }
+
+ public static int maxCommonDivisor(int m, int n) {
+ if (m < n) {
+ int temp = m;
+ m = n;
+ n = temp;
+ }
+ if (m % n == 0) {
+ return n;
+ } else {
+ return maxCommonDivisor(n, m % n);
+ }
+ }
+}
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 8d66398..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,227 +0,0 @@
-
- 4.0.0
- com.fr.plugin
- starter
- 10.0
- pom
-
- 10.0-RELEASE-SNAPSHOT
- ${project.basedir}/webroot/WEB-INF
-
-
- plugin-function
-
-
-
-
- com.fr.third
- fine-third
- ${common-version}
-
-
- com.fr.activator
- fine-activator
- ${common-version}
- compile
-
-
- com.fr.core
- fine-core
- ${common-version}
- compile
-
-
- com.fr.webui
- fine-webui
- ${common-version}
- compile
-
-
-
- com.fr.datasource
- fine-datasource
- ${common-version}
- compile
-
-
-
- com.fr.decision
- fine-decision
- ${common-version}
- compile
-
-
- com.fr.decision
- fine-decision-report
- ${common-version}
- compile
-
-
-
- com.fr.schedule
- fine-schedule
- ${common-version}
- compile
-
-
- com.fr.schedule
- fine-schedule-report
- ${common-version}
- compile
-
-
-
-
- com.fr.intelligence
- fine-swift
- ${common-version}
- compile
-
-
- com.fr.intelligence
- fine-accumulator
- ${common-version}
- compile
-
-
-
- com.fr.report
- fine-report-engine
- ${common-version}
- compile
-
-
-
- com.fr.report
- fine-report-designer
- ${common-version}
- compile
-
-
-
-
- io.socket
- socket.io-client
- 0.7.0
- compile
-
-
-
-
- org.aspectj
- aspectjrt
- 1.6.9
- compile
-
-
-
-
- org.swingexplorer
- swexpl
- 2.0
-
-
- org.swingexplorer
- swag
- 1.0
-
-
-
-
- org.apache.tomcat
- tomcat-catalina
- 8.5.32
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.44
-
-
-
- com.fr.third
- jxbrowser
- 6.23.1
-
-
-
- com.fr.third
- jxbrowser-mac
- 6.23.1
-
-
-
- junit
- junit
- 4.12
- test
-
-
- org.easymock
- easymock
- 3.5.1
- test
-
-
-
-
- ${web-inf-bucket}/classes
-
-
- maven-compiler-plugin
- 3.1
-
-
- 1.6
-
- none
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy-dependencies
-
-
-
- ${project.basedir}/webroot/WEB-INF/lib
-
-
-
-
-
-
-
-
-
- fanruan
- fanruan
- http://mvn.finedevelop.com/repository/maven-public/
-
- true
- always
- warn
-
-
-
-
-
- fanruan
- fanruan
- http://mvn.finedevelop.com/repository/maven-public/
-
- true
- always
- warn
-
-
-
-
\ No newline at end of file
diff --git a/readme.md b/readme.md
index ade69d0..99b001b 100644
--- a/readme.md
+++ b/readme.md
@@ -1,17 +1,14 @@
# 工程配置指南
-## 安装maven
-用于构建开发工程,文档参考:http://wiki.jikexueyuan.com/project/maven/environment-setup.html
-
-## 安装ant
-用于构建插件安装包,文档参考:http://wiki.jikexueyuan.com/project/ant/environment-setup.html
+## 安装gradle
+用于构建开发工程和插件包,文档参考:https://wiki.jikexueyuan.com/project/gradle/installing-gradle.html
## 配置开发工程
直接使用IntelliJ IDEA打开这个目录即可。
-如果需要复制jar包到webroot/WEB-INF/lib下,可以执行命令:```mvn install```
+如果需要复制jar包到webroot/WEB-INF/lib下,可以执行命令:```gradle install```
-**注意:**该工程依赖的jar为私有maven服务器,注意不要删除pom.xml中的repositories。
+**注意:**该工程依赖的jar为私有maven服务器,地址在build.gradle的repositories中定义。
## 启动应用程序
@@ -29,11 +26,13 @@
### 选择报表运行环境
一般情况启动设计器的时候,会自动使用上一次使用的报表运行环境,我们这里需要新建一个本地报表运行环境,并指向这个开发目录下的webroot/WEB-INF目录。
+## 增加新的插件
+将插件源码目录放到跟目录下,同时修改settings.gradle文件,再刷新gradle配置即可。
## 修改依赖的jar版本
-只需要更改pom.xml中的common-version属性即可。
+只需要更改build.gradle中的fineVersion变量即可。
-|common-version|含义|
+|fineVersion|含义|
|--------------|----|
|10.0-RELEASE-SNAPSHOT|10.0的测试版本快照|
|10.0-SNAPSHOT|10.0的正式版本快照|
diff --git a/settings.gradle b/settings.gradle
index 7f9935d..f248648 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,7 +1,3 @@
-/*
- * This file was generated by the Gradle 'init' task.
- */
-
rootProject.name = 'starter'
include(':plugin-function')
-include(':demo-chart-pie')
+include(':plugin-function2')