Skip to content

Commit

Permalink
Refactor packages (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksclarke authored Dec 13, 2024
1 parent ec8564d commit b40c5d7
Show file tree
Hide file tree
Showing 13 changed files with 455 additions and 62 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
cache: maven
distribution: ${{ matrix.jdk }}
java-version: ${{ matrix.java }}
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Set release version
shell: bash
Expand All @@ -63,9 +66,10 @@ jobs:
with:
maven-version: ${{ matrix.maven }}

- name: Build with Maven
- name: Release with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.BUILD_PASSPHRASE }}
MAVEN_GPG_KEY: ${{ secrets.BUILD_KEY }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
Expand Down
45 changes: 36 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<modelVersion>4.0.0</modelVersion>

<artifactId>jsh4jpv3</artifactId>
<artifactId>jpv3-webrepl</artifactId>
<packaging>jar</packaging>
<version>${revision}</version>

<name>jsh4jpv3</name>
<name>jpv3-webrepl</name>
<description>A JShell service to evaluate JPv3 scripts</description>
<url>http://projects.freelibrary.info/jiiify-presentation</url>

Expand Down Expand Up @@ -46,6 +46,7 @@
<!-- Dependency versions -->
<microhttp.version>0.11</microhttp.version>
<jpv3.version>0.0.0-SNAPSHOT</jpv3.version>
<freelib.utils.version>5.0.7</freelib.utils.version>

<!-- Configuring Sonar to use the right (i.e., webrepl) branch -->
<sonar.branch.target>webrepl</sonar.branch.target>
Expand All @@ -54,10 +55,11 @@
<!-- Plugin related versions -->
<docker.plugin.version>0.45.0</docker.plugin.version>
<deploy.plugin.version>3.1.3</deploy.plugin.version>
<maven.shade.version>3.6.0</maven.shade.version>
<shade.plugin.version>3.6.0</shade.plugin.version>

<!-- Test dependency versions -->
<junit.version>5.11.0</junit.version>
<mockito.version>5.14.2</mockito.version>

<!-- Skip the requirement that none of the dependencies are snapshot versions -->
<enforcer.skip>true</enforcer.skip>
Expand Down Expand Up @@ -85,6 +87,11 @@
<artifactId>jiiify-presentation-v3</artifactId>
<version>${jpv3.version}</version>
</dependency>
<dependency>
<groupId>info.freelibrary</groupId>
<artifactId>freelib-utils</artifactId>
<version>${freelib.utils.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
Expand All @@ -97,6 +104,18 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -113,7 +132,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.version}</version>
<version>${shade.plugin.version}</version>
<executions>
<execution>
<id>uber-jar</id>
Expand Down Expand Up @@ -149,7 +168,7 @@
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>info.freelibrary.jsh4jvp3.Server</mainClass>
<mainClass>info.freelibrary.iiif.webrepl.Server</mainClass>
</transformer>
</transformers>
</configuration>
Expand Down Expand Up @@ -183,6 +202,13 @@

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down Expand Up @@ -214,7 +240,10 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jacoco.agent.arg}</argLine>
<argLine>${jacoco.agent.arg} -javaagent:${org.mockito:mockito-core:jar}</argLine>
<environmentVariables>
<HTTP_PORT>${test.http.port}</HTTP_PORT>
</environmentVariables>
</configuration>
</plugin>

Expand Down Expand Up @@ -257,8 +286,6 @@
<platform>linux/amd64</platform>
<platform>linux/arm64/v8</platform>
</platforms>
<!-- Multi-arch builds don't work on GA because containerd isn't supported (cf. reason number two on
https://github.com/fabric8io/docker-maven-plugin/issues/1557#issuecomment-1325203489) -->
<attestations>
<sbom>${docker.sbom}</sbom>
<provenance>${docker.provenance}</provenance>
Expand Down Expand Up @@ -330,7 +357,7 @@
</execution>

<!-- Deploys the application's Docker image -->

<execution>
<id>docker-deploy</id>
<phase>deploy</phase>
Expand Down
4 changes: 2 additions & 2 deletions src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ RUN apk add --no-cache nano curl && \
addgroup -S jpv3 && \
adduser -S jpv3 -G jpv3 -s bash

COPY --chown=jpv3:jpv3 --chmod=0400 "maven/jsh4jpv3-${project.version}-uber.jar" "/opt/jpv3.jar"
COPY --chown=jpv3:jpv3 --chmod=0400 "maven/${project.name}-${project.version}-uber.jar" "/opt/${project.name}.jar"
COPY --chown=jpv3:jpv3 --chmod=0400 "imports.jsh" "/etc/jshell/imports.jsh"

EXPOSE 8888

USER jpv3

CMD ["sh", "-c", "exec java ${JAVA_OPTS} -jar /opt/jpv3.jar"]
CMD ["sh", "-c", "exec java ${JAVA_OPTS} -jar /opt/${project.name}.jar"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package info.freelibrary.jsh4jvp3;
package info.freelibrary.iiif.webrepl;

/**
* The application's configuration variables.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package info.freelibrary.jsh4jvp3;
package info.freelibrary.iiif.webrepl;

import static info.freelibrary.util.Constants.EOL;

Expand Down Expand Up @@ -55,19 +55,28 @@ public void accept(final Diag aDiagnostic) {
int start = (int) aDiagnostic.getStartPosition();
int end = (int) aDiagnostic.getEndPosition();

// Isolate and highlight the problem (with brackets)
if (start == end) {
myBuffer.insert(start, START).insert(start + START.length(), END);
} else {
myBuffer.insert(start, START).insert(end, END);
myBuffer.insert(start, START).insert(end + START.length(), END);
}

end = myBuffer.indexOf(TEMPLATE_START) + TEMPLATE_START.length() + 2;
start = myBuffer.length() - 4;
// If the code snippet includes the multi-line template, remove it
if (myBuffer.toString().contains(TEMPLATE_START)) {
end = myBuffer.indexOf(TEMPLATE_START) + TEMPLATE_START.length() + 2;
start = myBuffer.length() - 4;

myBuffer.delete(start, myBuffer.length()).delete(0, end);
myBuffer.delete(start, myBuffer.length()).delete(0, end);
}

// Add line numbers to what's returned
code = StringUtils.addLineNumbers(myBuffer.toString());

// Zero out the output buffer
myBuffer.setLength(0);

// Format the output and prepare to return it
myBuffer.append(INTRO).append(EOLX2).append(code).append(EOLX2).append(HEADER).append(message).append(EOL);
}

Expand Down
Loading

0 comments on commit b40c5d7

Please sign in to comment.