Skip to content

Commit b06b536

Browse files
authored
Add PObserveJavaUnitTest and gihub workflow to publish to maven (#892)
1 parent 16c66c0 commit b06b536

18 files changed

+1973
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish PObserveJavaUnitTest to Maven Central
2+
3+
on:
4+
push:
5+
branches: [ "maven-publish-**" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
working-directory: Src/PObserve/PObserveJavaUnitTest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '17'
23+
distribution: 'temurin'
24+
25+
- name: Cache Maven dependencies
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.m2
29+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
30+
restore-keys: ${{ runner.os }}-m2
31+
32+
- name: Import GPG key
33+
uses: crazy-max/ghaction-import-gpg@v6
34+
with:
35+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
36+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
37+
38+
- name: Create Maven settings.xml
39+
run: |
40+
mkdir -p ~/.m2
41+
cat > ~/.m2/settings.xml << 'EOF'
42+
<?xml version="1.0" encoding="UTF-8"?>
43+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
44+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
45+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
46+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
47+
<servers>
48+
<server>
49+
<id>central</id>
50+
<username>${{ secrets.MAVEN_USERNAME }}</username>
51+
<password>${{ secrets.MAVEN_PASSWORD }}</password>
52+
</server>
53+
<server>
54+
<id>gpg.passphrase</id>
55+
<passphrase>${{ secrets.GPG_PASSPHRASE }}</passphrase>
56+
</server>
57+
</servers>
58+
</settings>
59+
EOF
60+
61+
- name: Publish PObserveJavaUnitTest to Maven Central
62+
run:
63+
mvn clean deploy -P release
64+
env:
65+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/build
2+
/eclipse-bin
3+
.classpath
4+
.project
5+
.settings/
6+
target/
7+
8+
# Ignore IntelliJ project files
9+
*.iml
10+
/bin/
11+
.idea
12+
out/
13+
14+
out.log
15+
all.log
16+
17+
annotation-generated-src
18+
annotation-generated-tst
19+
20+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PObserveJavaUnitTest
2+
3+
## Overview
4+
5+
PObserveBaseTest automatically checks the correctness of the implementation by checking unit test logs against the specified monitors in PSpec.
6+
7+
## Prerequisites
8+
9+
- JDK 17 or higher
10+
- Maven 3.6.0 or higher
11+
12+
## Build and Run Instructions
13+
14+
### 1. Building the Project
15+
16+
To build the project, run:
17+
18+
```bash
19+
mvn clean compile
20+
```
21+
22+
This will compile the main source code in `src/main/java`.
23+
24+
### 2. Running Tests
25+
26+
To compile and run the tests:
27+
28+
```bash
29+
mvn test
30+
```
31+
32+
### 3. Building a JAR Package
33+
34+
To create a JAR package of the library:
35+
36+
```bash
37+
mvn package
38+
```
39+
40+
### 4. Complete Build
41+
42+
For a full build including tests, static analysis, and documentation:
43+
44+
```bash
45+
mvn clean install
46+
```
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>io.github.p-org</groupId>
8+
<artifactId>pobserve-java-unit-test</artifactId>
9+
<version>1.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>PObserve Java Unit Test</name>
13+
<description>JUnit integration for P specifications runtime verification</description>
14+
<url>https://github.com/p-org/P</url>
15+
16+
<licenses>
17+
<license>
18+
<name>MIT License</name>
19+
<url>https://spdx.org/licenses/MIT.html</url>
20+
</license>
21+
</licenses>
22+
23+
<scm>
24+
<connection>scm:git:[email protected]:p-org/P.git</connection>
25+
<developerConnection>scm:git:ssh://github.com:p-org/P.git</developerConnection>
26+
<url>https://github.com/p-org/P/tree/master</url>
27+
</scm>
28+
29+
<developers>
30+
<developer>
31+
<name>Ankush Desai</name>
32+
</developer>
33+
<developer>
34+
<name>Christine Zhou</name>
35+
</developer>
36+
</developers>
37+
38+
<dependencies>
39+
<!-- PObserve dependencies -->
40+
<dependency>
41+
<groupId>io.github.p-org</groupId>
42+
<artifactId>pobserve-commons</artifactId>
43+
<version>${pobserve.commons.version}</version>
44+
</dependency>
45+
46+
<!-- JUnit dependencies -->
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-api</artifactId>
50+
<version>${junit.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-params</artifactId>
55+
<version>${junit.version}</version>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.junit.jupiter</groupId>
60+
<artifactId>junit-jupiter-engine</artifactId>
61+
<version>${junit.version}</version>
62+
<scope>test</scope>
63+
</dependency>
64+
65+
<!-- Logging dependencies -->
66+
<dependency>
67+
<groupId>org.slf4j</groupId>
68+
<artifactId>slf4j-api</artifactId>
69+
<version>${slf4j.version}</version>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.apache.logging.log4j</groupId>
73+
<artifactId>log4j-core</artifactId>
74+
<version>2.20.0</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.apache.logging.log4j</groupId>
78+
<artifactId>log4j-slf4j2-impl</artifactId>
79+
<version>2.20.0</version>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.sonatype.central</groupId>
88+
<artifactId>central-publishing-maven-plugin</artifactId>
89+
<version>0.8.0</version>
90+
<extensions>true</extensions>
91+
<configuration>
92+
<publishingServerId>central</publishingServerId>
93+
<tokenAuth>true</tokenAuth>
94+
<autoPublish>true</autoPublish>
95+
<waitUntil>published</waitUntil>
96+
</configuration>
97+
</plugin>
98+
<plugin>
99+
<groupId>org.apache.maven.plugins</groupId>
100+
<artifactId>maven-compiler-plugin</artifactId>
101+
<version>3.10.0</version>
102+
<!-- <configuration>
103+
<forceJavacCompilerUse>true</forceJavacCompilerUse>
104+
<annotationProcessorPaths>
105+
<path>
106+
<groupId>org.projectlombok</groupId>
107+
<artifactId>lombok</artifactId>
108+
<version>1.18.36</version>
109+
</path>
110+
</annotationProcessorPaths>
111+
<source>17</source>
112+
<target>17</target>
113+
</configuration> -->
114+
</plugin>
115+
<plugin>
116+
<groupId>org.apache.maven.plugins</groupId>
117+
<artifactId>maven-surefire-plugin</artifactId>
118+
<version>3.1.2</version>
119+
</plugin>
120+
</plugins>
121+
</build>
122+
123+
<profiles>
124+
<profile>
125+
<id>release</id>
126+
<activation>
127+
<activeByDefault>false</activeByDefault>
128+
</activation>
129+
<build>
130+
<plugins>
131+
<plugin>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-source-plugin</artifactId>
134+
<version>2.4</version>
135+
<executions>
136+
<execution>
137+
<id>attach-sources</id>
138+
<goals>
139+
<goal>jar-no-fork</goal>
140+
</goals>
141+
</execution>
142+
</executions>
143+
</plugin>
144+
<plugin>
145+
<groupId>org.apache.maven.plugins</groupId>
146+
<artifactId>maven-jar-plugin</artifactId>
147+
<version>3.3.0</version>
148+
<executions>
149+
<execution>
150+
<id>empty-javadoc-jar</id>
151+
<phase>package</phase>
152+
<goals>
153+
<goal>jar</goal>
154+
</goals>
155+
<configuration>
156+
<classifier>javadoc</classifier>
157+
<classesDirectory>${basedir}</classesDirectory>
158+
<includes>
159+
<include>*.md</include>
160+
</includes>
161+
</configuration>
162+
</execution>
163+
</executions>
164+
</plugin>
165+
<plugin>
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-gpg-plugin</artifactId>
168+
<version>3.0.1</version>
169+
<executions>
170+
<execution>
171+
<id>sign-artifacts</id>
172+
<phase>verify</phase>
173+
<goals>
174+
<goal>sign</goal>
175+
</goals>
176+
</execution>
177+
</executions>
178+
</plugin>
179+
</plugins>
180+
</build>
181+
</profile>
182+
</profiles>
183+
184+
<distributionManagement>
185+
<repository>
186+
<id>central</id>
187+
<url>https://central.sonatype.com/api/v1/publisher/deployments/upload/</url>
188+
</repository>
189+
</distributionManagement>
190+
191+
<properties>
192+
<java.version>17</java.version>
193+
<maven.compiler.source>${java.version}</maven.compiler.source>
194+
<maven.compiler.target>${java.version}</maven.compiler.target>
195+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
196+
<revision>1.0.0</revision>
197+
<junit.version>5.9.2</junit.version>
198+
<slf4j.version>2.0.5</slf4j.version>
199+
<!-- Add versions for pobserve dependencies when available -->
200+
<pobserve.commons.version>1.0.0</pobserve.commons.version>
201+
</properties>
202+
203+
</project>

0 commit comments

Comments
 (0)