Skip to content

Commit

Permalink
initial imports
Browse files Browse the repository at this point in the history
  • Loading branch information
umjammer committed Dec 19, 2024
0 parents commit 8d39e25
Show file tree
Hide file tree
Showing 10 changed files with 536 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
# schedule:
# - cron: '19 18 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

# server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
# settings-path: ${{ github.workspace }} # location for the settings.xml file

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

- name: Build with Maven
run: mvn -B package --file pom.xml -DskipTests
#run: mvn package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml -DskipTests
#env:
# GITHUB_TOKEN: ${{ github.token }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
35 changes: 35 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Java CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
#server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
#settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Build with Maven
run: mvn -B package --file pom.xml
#run: mvn package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml
#env:
# GITHUB_TOKEN: ${{ github.token }}
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[![GitHub Packages](https://github.com/umjammer/careless-maven-plugin/actions/workflows/maven-publish.yml/badge.svg)](https://github.com/umjammer?tab=packages&repo_name=careless-maven-plugin)
[![Release](https://jitpack.io/v/umjammer/careless-maven-plugin.svg)](https://jitpack.io/#umjammer/careless-maven-plugin)
[![Java CI](https://github.com/umjammer/careless-maven-plugin/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/careless-maven-plugin/actions/workflows/maven.yml)
[![CodeQL](https://github.com/umjammer/careless-maven-plugin/actions/workflows/codeql.yml/badge.svg)](https://github.com/umjammer/careless-maven-plugin/actions/workflows/codeql.yml)
![Java](https://img.shields.io/badge/Java-17-b07219)

# careless-maven-plugin

⚠️ eliminates human errors.

## Install

* [maven](https://jitpack.io/#umjammer/careless-maven-plugin)

## Usage

```xml
<config>
<checks>
<check path="pom.xml" where="" match="21" />
<check path=".github/workflow/maven.yml" where="project.version" match="21" />
<check path=".github/workflow/maven-publish.yml" where="project.version" match="21" />
<check path=".github/workflow/cldeql.yml" where="project.version" match="21" />
<check path=".jitpack.yml" where="jdk.version" match="21" />
<check path="README.md" where="grep:-(\d\d)-pink" match="21" />
</checks>
</config>
```

* where
* file is xml(.xml) ... xpath
* file is yaml(.yml) ... yaml-path
* prefix (prefix:...)
* grep:regex

## Preference

* https://github.com/yaml-path/YamlPath
* https://github.com/snakeyaml/snakeyaml

## TODO

* checkstyle
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
96 changes: 96 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>vavi</groupId>
<artifactId>careless-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<configuration>
<release>17</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.9.9</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.github.yaml-path</groupId>
<artifactId>yaml-path</artifactId>
<version>0.0.12</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.14</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
46 changes: 46 additions & 0 deletions src/main/java/vavi/maven/careless/CarelessMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 by Naohide Sano, All rights reserved.
*
* Programmed by Naohide Sano
*/

package vavi.maven.careless;

import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;


/**
* CarelessMojo.
*
* @author <a href="mailto:umjammer@gmail.com">Naohide Sano</a> (nsano)
* @version 0.00 2024-09-07 nsano initial version <br>
*/
@Mojo(name = "careless")
public class CarelessMojo implements org.apache.maven.plugin.Mojo {

private Log log;


@Parameter(property = "constantName", required = true)
private String constantName;

@Parameter(property = "expectedValue", required = true)
private String expectedValue;

@Override
public void execute() {
log.info("Hello, world");
}

@Override
public void setLog(Log log) {
this.log = log;
}

@Override
public Log getLog() {
return log;
}
}
Loading

0 comments on commit 8d39e25

Please sign in to comment.