Skip to content
Permalink
Browse files
Bump extension daffodilVersion to 3.2.1:
- Add "daffodilVersion" entry to package.json
- Update build.sbt to get daffodilVersion by reading the package.json
- Update the extension to have a method for getting the daffodilVersion from the package.json
- Create unit test for extension that it gets the proper daffodilVersion given a file path
- Fix bash and bat templates to not hard code the app classpath
  - Had to make new variable inside of the templates, that would be sent for the adding of debug classpaths to the app classpath. As app classpath is a READ only variable

Closes #74
Closes #75
  • Loading branch information
Shanedell committed Feb 2, 2022
1 parent 53580b0 commit 9177397df5e6e3a2043c34bcee526e7b20d735a4
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 13 deletions.
@@ -15,7 +15,10 @@
* limitations under the License.
*/

lazy val daffodilVer = "3.2.1"
import play.api.libs.json._

lazy val packageData = Json.parse(scala.io.Source.fromFile("./package.json").mkString).as[JsObject]
lazy val daffodilVer = packageData("daffodilVersion").as[String]

lazy val commonSettings = {
Seq(
@@ -3,6 +3,7 @@
"displayName": "Apache Daffodil Schema Debugger",
"description": "VS Code extension for Apache Daffodil DFDL schema debugging",
"version": "1.0.0-SNAPSHOT",
"daffodilVersion": "3.2.1",
"publisher": "asf",
"author": "Apache Daffodil",
"license": "Apache-2.0",
@@ -20,3 +20,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17")
addSbtPlugin("org.musigma" % "sbt-rat" % "0.7.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3")
addSbtPlugin("com.github.battermann" % "sbt-json" % "0.5.0")
@@ -264,14 +264,16 @@ run() {
fi

if [[ "$DAFFODIL_DEBUG_CLASSPATH" != "" ]]; then
app_classpath="$app_classpath:$DAFFODIL_DEBUG_CLASSPATH"
new_classpath="$app_classpath:$DAFFODIL_DEBUG_CLASSPATH"
else
new_classpath="$app_classpath"
fi

# run sbt
execRunner "$java_cmd" \
${java_opts[@]} \
"${java_args[@]}" \
-cp "$(fix_classpath "$app_classpath")" \
-cp "$(fix_classpath "$new_classpath")" \
"${mainclass[@]}" \
"${app_commands[@]}" \
"${residual_args[@]}"
@@ -365,8 +367,7 @@ declare -r app_home="$(realpath "$(dirname "$real_script_path")")"
declare -r lib_dir="$(realpath "${app_home}/../lib")"
declare -a app_mainclass=(org.apache.daffodil.debugger.dap.DAPodil)

declare -r script_conf_file="${app_home}/../conf/application.ini"
declare -a app_classpath="$lib_dir/org.apache.daffodil.daffodil-debugger-1.0.0-SNAPSHOT.jar:$lib_dir/org.scala-lang.scala-library-2.12.13.jar:$lib_dir/org.apache.daffodil.daffodil-sapi_2.12-3.1.0.jar:$lib_dir/org.apache.daffodil.daffodil-runtime1_2.12-3.1.0.jar:$lib_dir/ch.qos.logback.logback-classic-1.2.3.jar:$lib_dir/com.microsoft.java.com.microsoft.java.debug.core-0.31.1.jar:$lib_dir/co.fs2.fs2-io_2.12-3.0.4.jar:$lib_dir/com.monovore.decline-effect_2.12-2.1.0.jar:$lib_dir/org.typelevel.log4cats-slf4j_2.12-2.1.0.jar:$lib_dir/org.apache.daffodil.daffodil-core_2.12-3.1.0.jar:$lib_dir/com.lihaoyi.os-lib_2.12-0.7.6.jar:$lib_dir/org.scala-lang.modules.scala-xml_2.12-1.3.0.jar:$lib_dir/org.scala-lang.modules.scala-parser-combinators_2.12-1.1.2.jar:$lib_dir/com.ibm.icu.icu4j-69.1.jar:$lib_dir/xerces.xercesImpl-2.12.1.jar:$lib_dir/xml-resolver.xml-resolver-1.2.jar:$lib_dir/commons-io.commons-io-2.8.0.jar:$lib_dir/com.typesafe.config-1.4.1.jar:$lib_dir/org.jdom.jdom2-2.0.6.jar:$lib_dir/com.fasterxml.woodstox.woodstox-core-6.2.6.jar:$lib_dir/com.fasterxml.jackson.core.jackson-core-2.12.3.jar:$lib_dir/org.apache.daffodil.daffodil-io_2.12-3.1.0.jar:$lib_dir/org.apache.daffodil.daffodil-udf_2.12-3.1.0.jar:$lib_dir/ch.qos.logback.logback-core-1.2.3.jar:$lib_dir/org.slf4j.slf4j-api-1.7.30.jar:$lib_dir/org.apache.commons.commons-lang3-3.6.jar:$lib_dir/com.google.code.gson.gson-2.7.jar:$lib_dir/io.reactivex.rxjava2.rxjava-2.1.1.jar:$lib_dir/org.reactivestreams.reactive-streams-1.0.0.jar:$lib_dir/co.fs2.fs2-core_2.12-3.0.4.jar:$lib_dir/com.comcast.ip4s-core_2.12-3.0.3.jar:$lib_dir/com.monovore.decline_2.12-2.1.0.jar:$lib_dir/org.typelevel.cats-effect_2.12-3.1.1.jar:$lib_dir/org.typelevel.log4cats-core_2.12-2.1.0.jar:$lib_dir/org.apache.daffodil.daffodil-runtime1-unparser_2.12-3.1.0.jar:$lib_dir/com.lihaoyi.geny_2.12-0.6.9.jar:$lib_dir/xml-apis.xml-apis-1.4.01.jar:$lib_dir/org.codehaus.woodstox.stax2-api-4.2.1.jar:$lib_dir/org.apache.daffodil.daffodil-lib_2.12-3.1.0.jar:$lib_dir/org.typelevel.cats-core_2.12-2.6.1.jar:$lib_dir/org.scodec.scodec-bits_2.12-1.1.27.jar:$lib_dir/org.typelevel.literally_2.12-1.0.2.jar:$lib_dir/org.typelevel.cats-effect-kernel_2.12-3.1.1.jar:$lib_dir/org.typelevel.cats-effect-std_2.12-3.1.1.jar:$lib_dir/org.typelevel.cats-kernel_2.12-2.6.1.jar:$lib_dir/org.typelevel.simulacrum-scalafix-annotations_2.12-0.5.4.jar"
${{template_declares}}

# java_cmd is overrode in process_args when -java-home is used
declare java_cmd=$(get_java_cmd)
@@ -55,9 +55,7 @@ rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPT
set _JAVA_PARAMS=
set _APP_ARGS=

set "APP_CLASSPATH=%APP_LIB_DIR%\org.apache.daffodil.daffodil-debugger-1.0.0-SNAPSHOT.jar;%APP_LIB_DIR%\org.scala-lang.scala-library-2.12.13.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-sapi_2.12-3.1.0.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-runtime1_2.12-3.1.0.jar;%APP_LIB_DIR%\ch.qos.logback.logback-classic-1.2.3.jar;%APP_LIB_DIR%\com.microsoft.java.com.microsoft.java.debug.core-0.31.1.jar;%APP_LIB_DIR%\co.fs2.fs2-io_2.12-3.0.4.jar;%APP_LIB_DIR%\com.monovore.decline-effect_2.12-2.1.0.jar;%APP_LIB_DIR%\org.typelevel.log4cats-slf4j_2.12-2.1.0.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-core_2.12-3.1.0.jar;%APP_LIB_DIR%\com.lihaoyi.os-lib_2.12-0.7.6.jar;%APP_LIB_DIR%\org.scala-lang.modules.scala-xml_2.12-1.3.0.jar;%APP_LIB_DIR%\org.scala-lang.modules.scala-parser-combinators_2.12-1.1.2.jar;%APP_LIB_DIR%\com.ibm.icu.icu4j-69.1.jar;%APP_LIB_DIR%\xerces.xercesImpl-2.12.1.jar;%APP_LIB_DIR%\xml-resolver.xml-resolver-1.2.jar;%APP_LIB_DIR%\commons-io.commons-io-2.8.0.jar;%APP_LIB_DIR%\com.typesafe.config-1.4.1.jar;%APP_LIB_DIR%\org.jdom.jdom2-2.0.6.jar;%APP_LIB_DIR%\com.fasterxml.woodstox.woodstox-core-6.2.6.jar;%APP_LIB_DIR%\com.fasterxml.jackson.core.jackson-core-2.12.3.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-io_2.12-3.1.0.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-udf_2.12-3.1.0.jar;%APP_LIB_DIR%\ch.qos.logback.logback-core-1.2.3.jar;%APP_LIB_DIR%\org.slf4j.slf4j-api-1.7.30.jar;%APP_LIB_DIR%\org.apache.commons.commons-lang3-3.6.jar;%APP_LIB_DIR%\com.google.code.gson.gson-2.7.jar;%APP_LIB_DIR%\io.reactivex.rxjava2.rxjava-2.1.1.jar;%APP_LIB_DIR%\org.reactivestreams.reactive-streams-1.0.0.jar;%APP_LIB_DIR%\co.fs2.fs2-core_2.12-3.0.4.jar;%APP_LIB_DIR%\com.comcast.ip4s-core_2.12-3.0.3.jar;%APP_LIB_DIR%\com.monovore.decline_2.12-2.1.0.jar;%APP_LIB_DIR%\org.typelevel.cats-effect_2.12-3.1.1.jar;%APP_LIB_DIR%\org.typelevel.log4cats-core_2.12-2.1.0.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-runtime1-unparser_2.12-3.1.0.jar;%APP_LIB_DIR%\com.lihaoyi.geny_2.12-0.6.9.jar;%APP_LIB_DIR%\xml-apis.xml-apis-1.4.01.jar;%APP_LIB_DIR%\org.codehaus.woodstox.stax2-api-4.2.1.jar;%APP_LIB_DIR%\org.apache.daffodil.daffodil-lib_2.12-3.1.0.jar;%APP_LIB_DIR%\org.typelevel.cats-core_2.12-2.6.1.jar;%APP_LIB_DIR%\org.scodec.scodec-bits_2.12-1.1.27.jar;%APP_LIB_DIR%\org.typelevel.literally_2.12-1.0.2.jar;%APP_LIB_DIR%\org.typelevel.cats-effect-kernel_2.12-3.1.1.jar;%APP_LIB_DIR%\org.typelevel.cats-effect-std_2.12-3.1.1.jar;%APP_LIB_DIR%\org.typelevel.cats-kernel_2.12-2.6.1.jar;%APP_LIB_DIR%\org.typelevel.simulacrum-scalafix-annotations_2.12-0.5.4.jar"
set "APP_MAIN_CLASS=org.apache.daffodil.debugger.dap.DAPodil"
set "SCRIPT_CONF_FILE=%APP_HOME%\conf\application.ini"
@@APP_DEFINES@@

rem Bundled JRE has priority over standard environment variables
if defined BUNDLED_JVM (
@@ -117,12 +115,14 @@ if defined CUSTOM_MAIN_CLASS (
)

if defined DAFFODIL_DEBUG_CLASSPATH (
set APP_CLASSPATH="%APP_CLASSPATH%;%DAFFODIL_DEBUG_CLASSPATH%"
set NEW_CLASSPATH="%APP_CLASSPATH%;%DAFFODIL_DEBUG_CLASSPATH%"
) else (
set NEW_CLASSPATH="%APP_CLASSPATH%"
)


rem Call the application and pass all arguments unchanged.
"%_JAVACMD%" !_JAVA_OPTS! !DAFFODIL_DEBUGGER_OPTS! -cp "%APP_CLASSPATH%" %MAIN_CLASS% !_APP_ARGS!
"%_JAVACMD%" !_JAVA_OPTS! !DAFFODIL_DEBUGGER_OPTS! -cp "%NEW_CLASSPATH%" %MAIN_CLASS% !_APP_ARGS!

@endlocal

@@ -15,6 +15,8 @@
* limitations under the License.
*/

import * as fs from 'fs'

export const dataEvent = 'daffodil.data'
export interface DaffodilData {
bytePos1b: number
@@ -50,3 +52,7 @@ export interface BuildInfo {
daffodilVersion: string
scalaVersion: string
}

export function getDaffodilVersion(filePath: fs.PathLike) {
return JSON.parse(fs.readFileSync(filePath).toString())['daffodilVersion']
}
@@ -25,6 +25,7 @@ import { LIB_VERSION } from './version'
import XDGAppPaths from 'xdg-app-paths'
import * as path from 'path'
import { regexp } from './utils'
import { getDaffodilVersion } from './daffodil'

const xdgAppPaths = XDGAppPaths({ name: 'daffodil-dap' })

@@ -41,9 +42,6 @@ class Artifact {
os.platform() === 'win32' ? 'daffodil-debugger.bat' : './daffodil-debugger'
}

const daffodilVersion = '3.1.0' // TODO: will become a runtime parameter driven by config or artifacts in the releases repo
const artifact = new Artifact(daffodilVersion)

// Class for getting release data
export class Release {
name: string
@@ -89,6 +87,12 @@ export async function getDebugger(
context: vscode.ExtensionContext,
config: vscode.DebugConfiguration
) {
// Get daffodilVersion
const daffodilVersion = getDaffodilVersion(
context.asAbsolutePath('./package.json')
)
const artifact = new Artifact(daffodilVersion)

// If useExistingServer var set to false make sure version of debugger entered is downloaded then ran
if (!config.useExistingServer) {
const delay = (ms: number) => new Promise((res) => setTimeout(res, ms))
@@ -17,8 +17,24 @@

import * as assert from 'assert'
import * as daffodil from '../daffodil'
import * as fs from 'fs'
import * as path from 'path'
import { before, after } from 'mocha'

suite('Daffodfil', () => {
const PROJECT_ROOT = path.join(__dirname, '../../')
const packageFile = path.join(PROJECT_ROOT, 'package-test.json')

// Create test package.json before anything else happens
before(() => {
fs.writeFileSync(packageFile, JSON.stringify({ daffodilVersion: '0.0.0' }))
})

// Delete test package.json after all tests are done
after(() => {
fs.unlinkSync(packageFile)
})

// suite to test all functions work properly
suite('interfaces', () => {
test('DaffodilData functions properly', () => {
@@ -119,4 +135,11 @@ suite('Daffodfil', () => {
assert.strictEqual(daffodil.configEvent, 'daffodil.config')
})
})

suite('getDaffodilVersion', () => {
test('getDaffodilVersion returns same version as file', () => {
var daffodilVersion = daffodil.getDaffodilVersion(packageFile)
assert.strictEqual(daffodilVersion, '0.0.0')
})
})
})

0 comments on commit 9177397

Please sign in to comment.