Skip to content

Commit

Permalink
#314 Add build of Maven Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Jan 6, 2025
1 parent e439d48 commit 7e32a85
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
49 changes: 49 additions & 0 deletions htmlSanityCheck-maven-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
plugins {
id "java-gradle-plugin"
}

// TODO do we need this?
description = 'HSC Maven Mojo'

dependencies {
implementation project(":htmlSanityCheck-core")
implementation('org.apache.maven.plugin-tools:maven-plugin-tools-api:3.15.0')
implementation('org.apache.maven.plugin-tools:maven-plugin-annotations:3.15.0')
}

tasks.register('copyClasses', Copy) {
dependsOn(compileJava)
from 'build/classes/java/main'
into 'build/maven/target/classes'
}

tasks.register('generatePom', Copy) {
dependsOn(copyClasses)
from 'src/main/maven'
into 'build/maven'
filesMatching("**/pom.*") {
expand(version: project.version)
}
}

tasks.register('generateMavenPlugin', CrossPlatformExec) {
dependsOn(generatePom)
// currently it seems to be the more or less only clean solution
// to generate a plugin.xml file to use maven directly
// if anyone has a better solution please let us know!
buildCommand 'mvn', '-nsu', '-U', '-f', 'build/maven/pom.xml', 'plugin:descriptor', '--batch-mode',
'-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
}

class CrossPlatformExec extends Exec {
void buildCommand(String command, String... commandArgs) {
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
executable = 'cmd'
args = ['/c', command]
} else {
executable = command
}
args(commandArgs.toList())
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.aim42.hatmlSanityChecker;
package org.aim42.htmlsanitychecker.maven;

import org.aim42.htmlsanitycheck.AllChecksRunner;
import org.aim42.htmlsanitycheck.Configuration;
Expand All @@ -8,9 +8,9 @@
import org.aim42.htmlsanitycheck.collect.PerRunResults;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.ResolutionScope;

import java.io.File;
Expand All @@ -28,7 +28,7 @@
* @goal sanity-check
* @phase verify
* @requiresDependencyResolution runtime
* @author Gernot Starke
* @author Thomas Ruhroth
*/
@Mojo(name = "sanity-check", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.RUNTIME)
public class HtmlSanityCheckMojo extends AbstractMojo {
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ develocity {

rootProject.name = 'htmlSanityCheck'

include('htmlSanityCheck-cli')
include('htmlSanityCheck-core')
include('htmlSanityCheck-gradle-plugin')
include('htmlSanityCheck-cli')
include('htmlSanityCheck-maven-plugin')

0 comments on commit 7e32a85

Please sign in to comment.