Skip to content

Commit

Permalink
Configure sonar build (#1)
Browse files Browse the repository at this point in the history
* Configure sonar build

* Rename project to luava

---------

Co-authored-by: kaklakariada <[email protected]>
  • Loading branch information
kaklakariada and kaklakariada authored Sep 22, 2024
1 parent ae027ff commit 818cbde
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 49 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@
"search.exclude": {
"build/generated/jextract": false,
},
"java.compile.nullAnalysis.mode": "automatic"
"java.compile.nullAnalysis.mode": "automatic",
"sonarlint.connectedMode.project": {
"connectionId": "kaklakariada-github",
"projectKey": "luava"
}
}
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# java-lua
# luava

An experimental Java library for embedding a Lua VM.

[![Build](https://github.com/kaklakariada/java-lua/actions/workflows/build.yml/badge.svg)](https://github.com/kaklakariada/java-lua/actions/workflows/build.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=bugs)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=coverage)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=duplicated_lines_density)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=org.itsallcode%3Aluava&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=org.itsallcode%3Aluava)

## Development

### Check for Dependency Updates

```sh
./gradlew dependencyUpdates
```

### Run Tests

```sh
./gradlew check
```
30 changes: 29 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
plugins {
id 'java-library'
id 'jacoco'
id "com.github.ben-manes.versions" version "0.51.0"
id "org.sonarqube" version "5.1.0.4882"
}

version = '0.0.1'
group = 'org.itsallcode'

repositories {
mavenCentral()
}
Expand All @@ -19,6 +24,29 @@ java {
}
}

javadoc {
enabled = true
failOnError = true
excludes = ["org/itsallcode/luava/ffi/**"]
options.addBooleanOption('html5', true)
options.addStringOption('Xwerror', '-quiet')
}

jacocoTestReport {
reports {
xml.required = true
}
}

sonarqube {
properties {
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "kaklakariada-github"
}
}

tasks.sonarqube.dependsOn([tasks.jacocoTestReport])

testing {
suites {
test {
Expand Down Expand Up @@ -113,7 +141,7 @@ task generateNativeInterface(type: Exec, dependsOn: [tasks.unpackJextract]) {
commandLine jextractBinary,
'--include-dir', includeDir,
'--output', generatedSrc,
'--target-package', 'org.itsallcode.jlua.ffi',
'--target-package', 'org.itsallcode.luava.ffi',
'--library', 'lua',
'--header-class-name', 'Lua',
"$includeDir/all_lua.h"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}

rootProject.name = 'jlua'
rootProject.name = 'luava'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

public class FunctionCallException extends LuaException {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;

import org.itsallcode.jlua.ffi.Lua;
import org.itsallcode.jlua.ffi.lua_KFunction;
import org.itsallcode.jlua.ffi.lua_KFunction.Function;
import org.itsallcode.luava.ffi.Lua;
import org.itsallcode.luava.ffi.lua_KFunction;
import org.itsallcode.luava.ffi.lua_KFunction.Function;

class LowLevelLua implements AutoCloseable {
private final Arena arena;
Expand All @@ -30,13 +30,13 @@ void openLibs() {

void pcall(final int nargs, final int nresults, final int errfunc, final long ctx) {
final Function function = (final MemorySegment l, final int status, final long ctx1) -> {
System.out.println("Upcall callback");
return 0;
};
pcall(nargs, nresults, errfunc, ctx, function);
}

void pcall(final int nargs, final int nresults, final int errfunc, final long ctx, final Function upcallFunction) {
void pcall(final int nargs, final int nresults, final int errfunc, final long ctx,
final lua_KFunction.Function upcallFunction) {
final MemorySegment k = lua_KFunction.allocate(upcallFunction, arena);
final int error = Lua.lua_pcallk(state, nargs, nresults, errfunc, ctx, k);
if (error != 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

public class LuaException extends RuntimeException {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;

import org.itsallcode.jlua.ffi.Lua;
import org.itsallcode.luava.ffi.Lua;

public class LuaFunction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

public class LuaInterpreter implements AutoCloseable {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.nio.charset.StandardCharsets;

import org.itsallcode.jlua.ffi.Lua;
import org.itsallcode.luava.ffi.Lua;

class LuaStack {
private final MemorySegment state;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;

import org.itsallcode.jlua.ffi.Lua;
import org.itsallcode.luava.ffi.Lua;

public class LuaTable {
private final LuaStack stack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import java.util.Arrays;

import org.itsallcode.jlua.ffi.Lua;
import org.itsallcode.luava.ffi.Lua;

public enum LuaType {
NONE(Lua.LUA_TNONE()), NIL(Lua.LUA_TNIL()), BOOLEAN(Lua.LUA_TBOOLEAN()), LIGHT_USERDATA(Lua.LUA_TLIGHTUSERDATA()),
Expand Down
20 changes: 0 additions & 20 deletions src/test/java/org/itsallcode/jlua/LowLevelLuaTest.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.itsallcode.jlua;
package org.itsallcode.luava;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;


class LuaStackTest {
private LowLevelLua lua;
private LuaStack stack;
Expand Down

0 comments on commit 818cbde

Please sign in to comment.