Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
da9bcbe
Initial commit of java/gradle project
gerritdrost May 15, 2026
b5d15b2
Work on automatically generating wrapper using JExtract
Mahmuttumkaya Jul 6, 2026
d3eb14f
First attempt at building using gradle.
gerritdrost Jul 9, 2026
bcefbdb
Fully working code generation for PGM wrapper using JExtract in gradle
Mahmuttumkaya Jul 9, 2026
c21bcf5
Getting Java code for loading/checking PGM ready for production
gerritdrost Jul 21, 2026
282d76c
Add and apply checkstyle and PMD
wei-qiang Jul 27, 2026
1c458e3
Move example class to lfenergy package
gerritdrost Jul 31, 2026
1169ee0
Introduce spotless
wei-qiang Aug 3, 2026
fae4126
Add license header to gradle files (#2)
wei-qiang Aug 3, 2026
fa520b8
GitHub actions (#3)
wei-qiang Aug 4, 2026
445cf71
Update gradle wrapper
gerritdrost Aug 4, 2026
48f0420
Fix root project name
gerritdrost Aug 4, 2026
4a52a03
Rename last occurence of jpgm to libpower-grid-model-java in exceptio…
gerritdrost Aug 4, 2026
e7146ca
Improve README.md, remove all occurences of pgm-template-repo
gerritdrost Aug 5, 2026
3043e2a
Remove DSA references
djamelig Aug 14, 2026
0fdc1a9
Add Apache-2.0 license to gradle wrapper files
wei-qiang Aug 14, 2026
cb6843b
Remove PMD, Checkstyle and Spotless (#9)
wei-qiang Aug 20, 2026
5d13c19
Add Reuse in workflow Java Gradle CI (#15)
Mahmuttumkaya Aug 21, 2026
cbfd839
Set distribution to temurin (#10)
wei-qiang Aug 21, 2026
d37a5fe
Clean up unused properties in CI
Mahmuttumkaya Sep 3, 2026
d9586f1
Removed action create build tag in github actions
Mahmuttumkaya Sep 3, 2026
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
70 changes: 70 additions & 0 deletions .github/actions/setup-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: Java & Gradle Setup
description: Setup runtime

inputs:
java_version:
description: 'The Java version to install.'
required: false
default: '25'
gradle_version:
description: 'The Gradle version to install. It do not force using this gradle version in other workflow steps, normally the installed gradle version of the project will be used.'
required: false
default: '9.1.0'
fetch-depth:
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.'
default: '1'
enable_caching:
description: 'If build and configuration caching should be enabled or disabled.'
default: 'true'
enable_daemon:
description: 'If build should be done using a separate gradle daemon.'
default: 'false'

runs:
using: "composite"
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: ${{ inputs.fetch-depth }}

- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # 5.6.0
with:
java-version: ${{ inputs.java_version }}
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # 6.2.0
with:
gradle-version: ${{ inputs.gradle_version }}

- name: Cache Gradle
if: ${{ inputs.enable_caching == 'true' }}
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/settings.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Configure Gradle properties
shell: bash
env:
CACHING: ${{ inputs.enable_caching }}
DAEMON: ${{ inputs.enable_daemon }}
run: |
set -euo pipefail
mkdir -p ~/.gradle
{
echo "ci=true"
echo "org.gradle.caching=${CACHING}"
echo "org.gradle.configuration-cache=${CACHING}"
echo "org.gradle.daemon=${DAEMON}"
} >> ~/.gradle/gradle.properties
53 changes: 53 additions & 0 deletions .github/workflows/java-gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0

name: Java CI with Gradle for library

on:
push:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-test:
name: Build & Test
runs-on: ubuntu-latest
outputs:
build_tag: ${{ steps.create_tag.outputs.build_tag }}
environment:
name: ci
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1
with:
fetch-depth: 1
persist-credentials: false

- name: Setup runtime
uses: ./.github/actions/setup-runtime

- name: Cache Gradle
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }}

- name: Optimize Gradle
shell: bash
run: |
mkdir -p ~/.gradle
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties

- name: Build & Run Tests
run: ./gradlew build --configuration-cache

reuse-compliance:
name: REUSE Compliance
uses: ./.github/workflows/reuse-compliance.yml
178 changes: 178 additions & 0 deletions LICENSES/Apache-2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,33 @@ SPDX-License-Identifier: MPL-2.0

[![Power Grid Model logo](https://raw.githubusercontent.com/PowerGridModel/.github/main/artwork/svg/color.svg)](#)

# Power Grid Model template repository
# libpower-grid-model-java

## Usage

The PGM methods are available through class `org.lfenergy.pgm.PowerGridModelC`. The method names are identical to the method names in the C-documentation.

To load the native library there are two options:
- on supported architectures, the library can be autoloaded using `PGMLoader.autoload()`
- on other architecture, you can build and load the library yourself using `System.load(...)`, and verify if you've loaded it correctly using `PGMLoader.check()`.

## Supported architectures

- macOS ARM64
- macOS x86-64
- Linux ARM64
- Linux x86-64
- Windows x86-64

This is a template repository for the Power Grid Model project.
Only common and mandatory content is included in this repository.
The derived repositories should review and edit content relevant to the best practices and standards.

## Checklist after creating a repository from this template

Update the following items manually before publishing your repository:

- [ ] Rename the repository and update all references in this file.
- [ ] Replace all `pgm-template-repo` references across the repository, especially in this README and REUSE.toml.
- [ ] Replace the project title and description in this README.
- [ ] Ensure all third-party licenses are present in [LICENSES](https://github.com/PowerGridModel/pgm-template-repo/tree/main/LICENSES).
- [x] Rename the repository and update all references in this file.
- [x] Replace all `pgm-template-repo` references across the repository, especially in this README and REUSE.toml.
- [x] Replace the project title and description in this README.
- [ ] Ensure all third-party licenses are present in [LICENSES](https://github.com/PowerGridModel/libpower-grid-model-java/tree/main/LICENSES).

### Optional checks

Expand All @@ -28,22 +41,22 @@ Change these if applicable.
- [ ] Replace Power Grid Model project-specific links (for example contributing, support, release, security, and code of conduct links)
with links for your project.
- [ ] Add logos and badges corresponding to relevant pages
- [ ] Verify [LICENSE](https://github.com/PowerGridModel/pgm-template-repo/blob/main/LICENSE) copyright holder and year(s).
- [ ] Verify [LICENSE](https://github.com/PowerGridModel/libpower-grid-model-java/blob/main/LICENSE) copyright holder and year(s).
Also verify SPDX copyright headers in source and documentation files.
- [ ] Include documents present in [Home page of PGM org](https://github.com/PowerGridModel/.github/) in documentation if they are created.

## License

This project is licensed under the Mozilla Public License, version 2.0 - see
[LICENSE](https://github.com/PowerGridModel/pgm-template-repo/blob/main/LICENSE) for details.
[LICENSE](https://github.com/PowerGridModel/libpower-grid-model-java/blob/main/LICENSE) for details.

## Licenses third-party libraries

This project includes third-party libraries,
which are licensed under their own respective Open-Source licenses.
SPDX-License-Identifier headers are used to show which license is applicable.
The concerning license files can be found in the
[LICENSES](https://github.com/PowerGridModel/pgm-template-repo/tree/main/LICENSES) directory.
[LICENSES](https://github.com/PowerGridModel/libpower-grid-model-java/tree/main/LICENSES) directory.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# SPDX-License-Identifier: MPL-2.0

version = 1
SPDX-PackageName = "pgm-template-repo"
SPDX-PackageName = "libpower-grid-model-java"
SPDX-PackageSupplier = "Power Grid Model project <powergridmodel@lfenergy.org>"
SPDX-PackageDownloadLocation = "https://github.com/PowerGridModel/pgm-template-repo"
SPDX-PackageDownloadLocation = "https://github.com/PowerGridModel/libpower-grid-model-java"

[[annotations]]
path = "./**"
Expand Down
Loading