100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI updates: updated build config for rest and model packages
Rich Turner790870a7d5ad
diff --git a/gradle.properties b/gradle.propertiesindex ced8f1bb2..ca40f6ac1 100644--- a/gradle.properties+++ b/gradle.properties@@ -49,4 +49,5 @@ friendlyIdVersion = 1.0.1geotoolsVersion = 19.1firebaseAdminVersion = 6.1.0simpleJavaMailVersion = 5.0.4-jaywayJsonPathVersion = 2.4.0\ No newline at end of file+jaywayJsonPathVersion = 2.4.0+typescriptGeneratorVersion = 2.13.489\ No newline at end of filediff --git a/ui/component/model/build.gradle b/ui/component/model/build.gradleindex 171d87719..4b0590c16 100644--- a/ui/component/model/build.gradle+++ b/ui/component/model/build.gradle@@ -2,7 +2,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetectimport cz.habarta.typescript.generator.Jackson2Configurationapply plugin: "groovy"-apply plugin: 'cz.habarta.typescript-generator'+apply plugin: "cz.habarta.typescript-generator"buildscript {repositories {@@ -10,21 +10,18 @@ buildscript {jcenter()}dependencies {- classpath 'cz.habarta.typescript-generator:typescript-generator-gradle-plugin:2.13.489'+ classpath "cz.habarta.typescript-generator:typescript-generator-gradle-plugin:$typescriptGeneratorVersion"}}dependencies {compile resolveProject(":model")compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"- compile 'cz.habarta.typescript-generator:typescript-generator-core:2.13.489'+ compile "cz.habarta.typescript-generator:typescript-generator-core:$typescriptGeneratorVersion"}generateTypeScript {jsonLibrary = "jackson2"- classes = [- "org.openremote.model.http.RequestParams"- ]classPatterns = ["org.openremote.model.**"]diff --git a/ui/component/rest/build.gradle b/ui/component/rest/build.gradleindex 2535feb57..2abf8622e 100644--- a/ui/component/rest/build.gradle+++ b/ui/component/rest/build.gradle@@ -1,5 +1,5 @@apply plugin: "groovy"-apply plugin: 'cz.habarta.typescript-generator'+apply plugin: "cz.habarta.typescript-generator"buildscript {repositories {@@ -7,37 +7,80 @@ buildscript {jcenter()}dependencies {- classpath 'cz.habarta.typescript-generator:typescript-generator-gradle-plugin:2.13.489'+ classpath "cz.habarta.typescript-generator:typescript-generator-gradle-plugin:$typescriptGeneratorVersion"}}dependencies {compile resolveProject(":model")- compile 'cz.habarta.typescript-generator:typescript-generator-core:2.13.489'+ compile "cz.habarta.typescript-generator:typescript-generator-core:$typescriptGeneratorVersion"+ compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"+}++task generateTypescriptModelInfo(type: cz.habarta.typescript.generator.gradle.GenerateTask) {+ classPatterns = [+ "org.openremote.model.**"+ ]+ jsonLibrary = "jackson2"+ outputKind = "module"+ generateInfoJson = true+ excludeClassPatterns = [+ "org.openremote.model.http.*Constraint**",+ "org.openremote.model.event.shared.*Filter**",+ "org.openremote.model.util.**",+ "org.openremote.model.flow.**",+ "org.openremote.model.interop.**",+ "org.openremote.model.value.impl.**",+ "org.openremote.model.**Resource**"+ ]+ customTypeNamingFunction = "function(name, simpleName) { if (name.indexOf(\"\$\") > 0) return name.substr(name.lastIndexOf(\".\")+1).replace(\"\$\",\"\"); }"+ customTypeMappings = [+ "org.openremote.model.value.ObjectValue:{ [id: string]: any }",+ "org.openremote.model.value.ArrayValue:any[]",+ "org.openremote.model.value.NumberValue:number",+ "org.openremote.model.value.StringValue:string",+ "org.openremote.model.value.BooleanValue:boolean",+ "org.openremote.model.value.Value:any",+ "org.openremote.model.attribute.Meta:MetaItem[]"+ ]+ optionalProperties = "all" // TODO: cleanup model to be more explicit about optional params+ mapEnum = cz.habarta.typescript.generator.EnumMapping.asEnum+ jackson2Modules = [+ "com.fasterxml.jackson.datatype.jdk8.Jdk8Module",+ "org.openremote.model.ModelModule"+ ]}generateTypeScript {+ dependsOn generateTypescriptModelInfojsonLibrary = "jackson2"+ customTypeNamingFunction = "function(name, simpleName) { if (name.indexOf(\"\$\") > 0) return name.substr(name.lastIndexOf(\".\")+1).replace(\"\$\",\"\"); }"classPatterns = [- "org.openremote.model.**Resource"+ "org.openremote.model.**Resource"]customTypeMappings = [- "org.openremote.model.value.ObjectValue:object",- "org.openremote.model.value.ArrayValue:Array<any>",- "org.openremote.model.value.NumberValue:number",- "org.openremote.model.value.StringValue:string",- "org.openremote.model.value.BooleanValue:boolean",- "org.openremote.model.value.Value:any"+ "org.openremote.model.value.ObjectValue:{ [id: string]: any }",+ "org.openremote.model.value.ArrayValue:any[]",+ "org.openremote.model.value.NumberValue:number",+ "org.openremote.model.value.StringValue:string",+ "org.openremote.model.value.BooleanValue:boolean",+ "org.openremote.model.value.Value:any",+ "org.openremote.model.attribute.Meta:MetaItem[]"+ ]+ moduleDependencies = [+ new cz.habarta.typescript.generator.ModuleDependency(+ "@openremote/model",+ "Model",+ new File("$buildDir/typescript-generator/typescript-generator-info.json"),+ (String)null,+ (String)null+ )]outputFile = "src/restclient.ts"outputFileType = "implementationFile"outputKind = "module"mapEnum = cz.habarta.typescript.generator.EnumMapping.asEnum- jaxrsNamespacing = "perResource"- customTypeProcessor = "JaxRsClientOnlyProcessor"- importDeclarations = [- "import * as Model from \"@openremote/model\""- ]+ restNamespacing = "perResource"extensions = ["AggregatedApiClient","cz.habarta.typescript.generator.ext.AxiosClientExtension"diff --git a/ui/component/rest/src/main/java/JaxRsClientOnlyProcessor.java b/ui/component/rest/src/main/java/JaxRsClientOnlyProcessor.javadeleted file mode 100644index 4e4aaa10e..000000000--- a/ui/component/rest/src/main/java/JaxRsClientOnlyProcessor.java+++ /dev/null@@ -1,57 +0,0 @@-/*- * Copyright 2018, OpenRemote Inc.- *- * See the CONTRIBUTORS.txt file in the distribution for a- * full listing of individual contributors.- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <http://www.gnu.org/licenses/>.- */--import cz.habarta.typescript.generator.TsType;-import cz.habarta.typescript.generator.util.Utils;--import java.lang.reflect.Type;--/**- * Hacky way of getting the typescript generator to only output the client which assumes the model has already been output- * and will be imported when required; suggested way by repo owner is to use:- * <p>- * <a href="https://github.com/vojtechhabarta/typescript-generator/pull/276">Dependent modules</a>- */-public class JaxRsClientOnlyProcessor implements cz.habarta.typescript.generator.TypeProcessor {-- @Override- public Result processType(Type javaType, Context context) {- final Class<?> rawClass = Utils.getRawClassOrNull(javaType);- if (rawClass != null) {- if (!rawClass.getName().startsWith("org.openremote.model") || rawClass.getName().startsWith("org.openremote.model.value")) {- return null;- }- if (!rawClass.getName().endsWith("Resource")) {- String name = rawClass.getName();- String simpleName = rawClass.getSimpleName();- if (name.indexOf("$") > 0) {- simpleName = name.substring(name.lastIndexOf(".")+1).replace("$","");- }- if ("RequestParams".equals(simpleName)) {- simpleName = simpleName + "<any,any>";- }- simpleName = "Model." + simpleName;-- return new Result(new TsType.VerbatimType(simpleName));- }- }- return null;- }-}