Skip to content

Commit c560d98

Browse files
committed
Version 1.0.0
1 parent 766f9da commit c560d98

File tree

23 files changed

+3838
-17
lines changed

23 files changed

+3838
-17
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
.gradle
3+
.idea
4+
libs/*.jar

README.md

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,86 @@
11
# Introduction
2-
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project.
2+
The *autoscript-dbc* project provides DBC support for deploying automation scripts that contain the `configScript` metadata used by the VSCode Maximo Script Deploy extension, which is found [here](https://marketplace.visualstudio.com/items?itemName=sharptree.maximo-script-deploy).
33

44
# Getting Started
5-
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
6-
1. Installation process
7-
2. Software dependencies
8-
3. Latest releases
9-
4. API references
10-
11-
# Build and Test
12-
TODO: Describe and show how to build your code and run the tests.
13-
14-
# Contribute
15-
TODO: Explain how other users and developers can contribute to make your code better.
16-
17-
If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
18-
- [ASP.NET Core](https://github.com/aspnet/Home)
19-
- [Visual Studio Code](https://github.com/Microsoft/vscode)
20-
- [Chakra Core](https://github.com/Microsoft/ChakraCore)
5+
6+
## Copy Classes and script.dtd
7+
To use the *autoscript-dbc* extension, copy the compiled classes to the [SMP_HOME]/maximo/tools/maximo/classes directory, for example `/opt/IBM/SMP/maximo/tools/maximo/classes` (unix) or `C:\IBM\SMP\maximo\tools\maximo\classes` (windows).
8+
9+
The classes can be found in the build/classes/java/main folder of this project after calling the gradle assemble task or can be obtained in the zip and tar files provided under this project's GitHub Releases.
10+
11+
Copy the script.dtd from the project to the [SMP_HOME]/maximo/tools/maximo directory, for example `/opt/IBM/SMP/maximo/tools/maximo` (unix) or `C:\IBM\SMP\maximo\tools\maximo` (windows).
12+
13+
## Update Product XML
14+
The *autoscript-dbc* relies on injecting new DBC statements into the statement processor. To enable these new statements, add `<calloutclass>io.sharptree.maximo.dbmanage.AutoScriptExtCallout</calloutclass>` to your project's product XML as shown in the example below.
15+
16+
```xml
17+
<?xml version="1.0" encoding="UTF-8"?>
18+
<product>
19+
<name>Example Autoscript</name>
20+
<version>
21+
<major>1</major>
22+
<minor>0</minor>
23+
<modlevel>0</modlevel>
24+
<patch>1</patch>
25+
<build>20220314</build>
26+
</version>
27+
<dbmaxvarname>AUTOSCRIPTINST</dbmaxvarname>
28+
<dbscripts>example</dbscripts>
29+
<dbversion>V1000-1</dbversion>
30+
<lastdbversion>V1000-00</lastdbversion>
31+
<calloutclass>io.sharptree.maximo.dbmanage.AutoScriptExtCallout</calloutclass>
32+
</product>
33+
```
34+
## Use add_update_autoscript and remove_autoscript
35+
With the product XML file updated the `add_update_autoscript` and `remove_autoscript` statements are now available.
36+
37+
The `add_update_autoscript` requires a `path` and a `language` attribute. The `path` attribute is either a relative path from the DBC script file location or an absolute file path. The `language` attribute is either the literal value, `javascript` or `python`.
38+
39+
Below is an example DBC script using both a relative and absolute path.
40+
41+
```xml
42+
<?xml version="1.0" encoding="UTF-8"?>
43+
<!DOCTYPE script SYSTEM "script.dtd">
44+
<script author="Jason VenHuizen" scriptname="V1000_01">
45+
<description>Example</description>
46+
<statements>
47+
<!-- Relative path to python script -->
48+
<add_update_autoscript path="example.py" language="python"/>
49+
50+
<!-- Absolute path to python script -->
51+
<!-- /opt/src/scripts/example.js (unxi) or C:\opt\src\scripts\example.js (windows) -->
52+
<add_update_autoscript path="/opt/src/scripts/example.js" language="javascript"/>
53+
</statements>
54+
</script>
55+
```
56+
57+
> Note that it is required that the automation script source files contain the `scriptConfig` variable that is used by the VSCode Maximo Script Deploy extension. If this is not present the script will be unable to deploy.
58+
59+
The `remove_autoscript` requires the `name` attribute. This is the name of the automation script to remove from the target system.
60+
61+
Below is an example DBC script that removes an automation script named `EXAMPLESCRIP`
62+
63+
```xml
64+
<?xml version="1.0" encoding="UTF-8"?>
65+
<!DOCTYPE script SYSTEM "script.dtd">
66+
<script author="Jason VenHuizen" scriptname="V1000_01">
67+
<description>Example</description>
68+
<statements>
69+
<remove_autoscript name="EXAMPLESCRIPT"/>
70+
</statements>
71+
</script>
72+
```
73+
74+
# Build
75+
76+
## Maximo Dependencies
77+
To build the *autoscript-dbc* project, you will need the Maximo `businessobjects.jar` and the Maximo tools classes. The `businessobjects.jar` file can be obtained by unzipping the `maximo.ear` file and copying the file.
78+
79+
The Maximo tools classes are not provided as a jar file and therefore must be created. Open a terminal (unix) or command (windows) window and navigate to the [SMP_HOME]/maximo/tools/maximo/classes folder. Run the following command.
80+
```shell
81+
jar cf maximo-tools.jar *
82+
```
83+
Copy the `businessobjects.jar` and `maximo-tools.jar` to the project's `libs` directory.
84+
85+
## Gradle assembleDist
86+
To build the project run the gradle `assembleDist` task.

build.gradle.kts

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
plugins {
2+
java
3+
distribution
4+
}
5+
6+
val archivaUserName: String by project
7+
val archivaPassword: String by project
8+
9+
group = "io.sharptree"
10+
version = "1.0.0"
11+
12+
val vendor = "Sharptree"
13+
val product = "autoscript-dbc"
14+
val distro = "autoscript-dbc"
15+
16+
project.version = "1.0.0"
17+
18+
tasks.compileJava {
19+
sourceCompatibility = "1.8"
20+
targetCompatibility = "1.8"
21+
}
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
distributions {
28+
29+
val distribution by configurations.creating {
30+
extendsFrom(configurations.implementation.get())
31+
isCanBeResolved = true
32+
}
33+
34+
main {
35+
contents {
36+
into("applications/maximo/lib") {
37+
from("$buildDir/libs/${product.toLowerCase()}.jar")
38+
}
39+
40+
into("tools/maximo/classes") {
41+
includeEmptyDirs = false
42+
from(layout.buildDirectory.dir("classes/java/main")) {
43+
include("**/*.class")
44+
}
45+
}
46+
}
47+
}
48+
}
49+
50+
// Configure the distribution task to tar and gzip the results.
51+
tasks.distTar {
52+
compression = Compression.GZIP
53+
archiveExtension.set("tar.gz")
54+
}
55+
56+
tasks.assembleDist {
57+
finalizedBy("fixzip")
58+
59+
}
60+
61+
tasks.register("fixzip") {
62+
dependsOn("rezip", "retar", "releaseZip","releaseTar")
63+
64+
doLast {
65+
delete(layout.buildDirectory.asFile.get().path + File.separator + "distributions" + File.separator + "tmp")
66+
delete(layout.buildDirectory.asFile.get().path + File.separator + "distributions" + File.separator + "tmp2")
67+
}
68+
}
69+
70+
tasks.register("unzip") {
71+
dependsOn("assembleDist")
72+
val archiveBaseName = project.name + "-" + project.version
73+
val distDir = layout.buildDirectory.asFile.get().path + File.separator + "distributions"
74+
75+
doLast {
76+
copy {
77+
from(zipTree(tasks.distZip.get().archiveFile.get().asFile))
78+
into(distDir + File.separator + "tmp")
79+
}
80+
}
81+
}
82+
83+
tasks.register<Zip>("rezip") {
84+
dependsOn("unzip")
85+
val archiveBaseName = project.name + "-" + project.version
86+
val distDir = layout.buildDirectory.asFile.get().path + File.separator + "distributions"
87+
val baseDir = File(distDir + File.separator + "tmp" + File.separator + archiveBaseName)
88+
89+
archiveFileName.set("$archiveBaseName.zip")
90+
91+
from(baseDir) {
92+
exclude("**/*.jar", "**/lib")
93+
into("/")
94+
}
95+
}
96+
97+
tasks.register<Tar>("retar") {
98+
dependsOn("unzip")
99+
val archiveBaseName = project.name + "-" + project.version
100+
val distDir = layout.buildDirectory.asFile.get().path + File.separator + "distributions"
101+
val baseDir = File(distDir + File.separator + "tmp" + File.separator + archiveBaseName)
102+
103+
compression = Compression.GZIP
104+
archiveExtension.set("tar.gz")
105+
106+
from(baseDir) {
107+
exclude("**/*.jar", "**/lib")
108+
into("/")
109+
}
110+
}
111+
112+
tasks.jar {
113+
archiveFileName.set("${product.toLowerCase()}.jar")
114+
}
115+
116+
tasks.getByName("distTar").dependsOn("jar")
117+
tasks.getByName("distZip").dependsOn("jar")
118+
119+
tasks.jar {
120+
manifest {
121+
attributes(
122+
mapOf(
123+
"Implementation-Title" to product,
124+
"Created-By" to vendor,
125+
"Implementation-Version" to project.version
126+
)
127+
)
128+
}
129+
archiveBaseName.set(product.toLowerCase())
130+
}
131+
132+
tasks.register<Zip>("releaseZip") {
133+
dependsOn("unzip")
134+
val archiveBaseName = distro.toLowerCase() + "-" + project.version
135+
val distDir = layout.buildDirectory.asFile.get().path + File.separator + "distributions"
136+
val baseDir = File(distDir + File.separator + "tmp" + File.separator + archiveBaseName)
137+
138+
archiveFileName.set("$archiveBaseName-release.zip")
139+
140+
from(baseDir) {
141+
exclude("tmp/")
142+
exclude("applications/")
143+
exclude("tools/maximo/en/")
144+
into("/")
145+
}
146+
}
147+
148+
tasks.register<Tar>("releaseTar") {
149+
dependsOn("unzip")
150+
151+
val archiveBaseName = distro.toLowerCase() + "-" + project.version
152+
val distDir = layout.buildDirectory.asFile.get().path + File.separator + "distributions"
153+
val baseDir = File(distDir + File.separator + "tmp" + File.separator + archiveBaseName)
154+
155+
compression = Compression.GZIP
156+
archiveFileName.set("$archiveBaseName-release.tar.gz")
157+
archiveExtension.set("tar.gz")
158+
159+
from(baseDir) {
160+
exclude("tmp/")
161+
into("/")
162+
}
163+
}
164+
165+
166+
dependencies {
167+
168+
/*
169+
* The javax.servlet-api is required to compile DataBean classes, but is otherwise provided by WebSphere / WebLogic.
170+
*/
171+
compileOnly("javax.servlet:javax.servlet-api:4.0.1")
172+
173+
/*
174+
* The gson package is used to parse the scriptConfig JSON.
175+
*/
176+
@Suppress("GradlePackageUpdate") // We are matching what Maximo uses
177+
implementation("com.google.code.gson:gson:2.2.4")
178+
179+
/**
180+
* Maximo's libraries needed for compiling the application.
181+
*
182+
* asset-management - the businessobjects.jar
183+
* webclient - classes from the maximouiweb/WEB-INF/classes folder
184+
* tools - classes from the [SMP_HOME]/maximo/tools/maximo/classes folder
185+
*
186+
*/
187+
compileOnly(fileTree("libs") { listOf("*.jar") })
188+
189+
@Suppress("GradlePackageUpdate")
190+
compileOnly("org.jdom:jdom:1.1")
191+
@Suppress("GradlePackageUpdate")
192+
compileOnly("log4j:log4j:1.2.16")
193+
194+
}

gradle/wrapper/gradle-wrapper.jar

58.1 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)