Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4
ij_javascript_space_before_function_left_parenth = false

[{*.json,.eslintrc}]
indent_size = 2
41 changes: 41 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"env": {
"commonjs": true,
"es2017": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
],
"no-var": "error",
"prefer-const": "error",
"curly": "error",
"prefer-template": "error",
"brace-style": "error",
"padded-blocks": [
"error",
"never"
]
}
}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Java CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v2
with:
name: Package
path: staging
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/node
/out
/node_modules/
/test/*.class
/package-lock.json
/.nyc_output/
/coverage/
/.idea
*.iml
/target
25 changes: 18 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"name": "java-deserialization",
"version": "0.1.0",
"description": "Parse Java object serialization format using pure JavaScript",
"main": "src/index.js",
"main": "src/main/node/index.js",
"scripts": {
"test": "nyc --reporter=html --reporter=text-summary mocha test/*.js",
"gentest": "cd test && javac *.java && java GenerateTestCases > generated.js && npm test"
"built": "echo 'build here'",
"lint": "echo 'no linting setup yet'",
"test": "nyc --reporter=html --reporter=text-summary mocha src/test/node/*.js",
"gentest": "java -classpath target/classes io.github.gagern.nodeJavaDeserialization.GenerateTestCases > src/test/node/generated.js && npm test",
"package": "echo 'make publishable artifact here'"
},
"repository": {
"type": "git",
Expand All @@ -24,11 +27,19 @@
},
"homepage": "https://github.com/gagern/nodeJavaDeserialization#readme",
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^4.1.0",
"nyc": "^11.4.1"
"@types/node": "^10.17.55",
"chai": "^4.3.4",
"eslint": "^7.22.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"mocha": "^8.3.2",
"nyc": "^15.1.0",
"typescript": "^4.2.3"
},
"dependencies": {
"long": "^3.2.0"
"long": "^4.0.0"
},
"engines": {
"node": ">=18.0.0"
}
}
125 changes: 125 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>


<groupId>io.github.gagern</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>nodeJavaDeserialization</artifactId>
<packaging>jar</packaging>

<properties>
<frontend-maven-plugin.version>1.13.4</frontend-maven-plugin.version>
<node.version>v20.12.1</node.version>
<npm.version>10.5.0</npm.version>

<!-- min version eight for now -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm lint</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run lint</arguments>
</configuration>
</execution>
<execution>
<id>npm gentest</id>
<goals>
<goal>npm</goal>
</goals>
<phase>test-compile</phase>
<configuration>
<arguments>run gentest</arguments>
</configuration>
</execution>
<execution>
<id>npm test</id>
<goals>
<goal>npm</goal>
</goals>
<phase>test</phase>
<configuration>
<arguments>run test</arguments>
</configuration>
</execution>
<!-- <execution>-->
<!-- <id>storybook</id>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <phase>storybook</phase>-->
<!-- <configuration>-->
<!-- <arguments>run storybook</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->

<!-- <execution>-->
<!-- <id>npm integration</id>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <phase>integration-test</phase>-->
<!-- <configuration>-->
<!-- <arguments>run test:e2e</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<execution>
<id>npm package</id>
<goals>
<goal>npm</goal>
</goals>
<phase>package</phase>
<configuration>
<arguments>run package</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package io.github.gagern.nodeJavaDeserialization;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
Expand All @@ -10,12 +12,16 @@ class GenerateTestCases {

public static void main(String[] args) throws Exception {
System.out.print
("'use strict';\n" +
("//This is a generated file from GeneratedTestCases.java\n" +
"'use strict';\n" +
"\n" +
"const chai = require('chai');\n" +
"const expect = chai.expect;\n" +
"const zlib = require('zlib');\n" +
"const javaDeserialization = require('../');\n" +
"const javaDeserialization = require('../../main/node');\n" +
"\n" +
"// Register a classdata parser for the io.github.gagern.nodeJavaDeserialization.CompletelyCustomFormat test.\n" +
"javaDeserialization.registerClassDataParser('io.github.gagern.nodeJavaDeserialization.CompletelyCustomFormat', '0000000000000001', cls => ({}));\n" +
"\n" +
"function testCase(b64data, checks) {\n" +
" return function() {\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package io.github.gagern.nodeJavaDeserialization;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Loading