Skip to content

Commit

Permalink
#309 Move respective code to core module
Browse files Browse the repository at this point in the history
This includes all Java code, all resources, and most parts of Groovy code.
  • Loading branch information
ascheman committed Oct 19, 2023
1 parent 9f29838 commit ce36f41
Show file tree
Hide file tree
Showing 106 changed files with 59 additions and 49 deletions.
42 changes: 42 additions & 0 deletions htmlSanityCheck-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
repositories {
jcenter()
// mavenCentral()
}

apply plugin: 'java'
apply plugin: 'groovy'

dependencies {

testImplementation(
'junit:junit:4.12',
'org.spockframework:spock-core:1.3-groovy-2.5',
'org.slf4j:slf4j-simple:2.0.7'
)

// implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'
implementation "org.slf4j:slf4j-api:2.0.7"

// jsoup is our awesome html parser, see jsoup.org
implementation group: 'org.jsoup', name: 'jsoup', version: '1.16.1'
// Use Groovy which corresponds to Gradle version (of hsc build)
implementation 'org.codehaus.groovy:groovy-all:2.5.4'
// Since Groovy 2.5 it is necessary to import dateutil separately
implementation 'org.codehaus.groovy:groovy-dateutil:2.5.4'
}

task copyResourceImages(type: Copy) {
from('src/main/resources') {
include '**/*.png'
}
into processResources.destinationDir
}

processResources {
dependsOn copyResourceImages

exclude '**/*.png'
inputs.property "version", project.version
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [version: project.version])
println "after processResources config, version= ${project.version}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class Configuration {
* We need at least one html file as input, maybe several
* @param configuration instance
*
* srcDocs needs to be of type {@link org.gradle.api.file.FileCollection}
* srcDocs needs to be of type {@link FileCollection}
* to be Gradle-compliant
*/
Boolean isValid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import org.aim42.htmlsanitycheck.collect.PerRunResults
import org.aim42.htmlsanitycheck.collect.SingleCheckResults
import org.aim42.htmlsanitycheck.collect.SinglePageResults

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck

import junit.framework.TestCase
import org.aim42.htmlsanitycheck.check.AllCheckers
import org.aim42.htmlsanitycheck.collect.SinglePageResults
import org.junit.Test
Expand Down Expand Up @@ -37,16 +38,16 @@ class AllChecksRunnerTest extends GroovyTestCase {
// title = "hsc"
int expected = AllCheckers.checkerClazzes.size()

assertEquals("expected $expected kinds of checks", expected, pageResults.singleCheckResults.size())
TestCase.assertEquals("expected $expected kinds of checks", expected, pageResults.singleCheckResults.size())

assertEquals("expected 0 items checked", 0, pageResults.nrOfItemsCheckedOnPage())
TestCase.assertEquals("expected 0 items checked", 0, pageResults.nrOfItemsCheckedOnPage())

assertEquals("expected 0 findings", 0, pageResults.nrOfFindingsOnPage())
TestCase.assertEquals("expected 0 findings", 0, pageResults.nrOfFindingsOnPage())

assertEquals("expected hsc title", "hsc", pageResults.pageTitle)
TestCase.assertEquals("expected hsc title", "hsc", pageResults.pageTitle)

String tmpFileName = tmpFile.name
assertEquals("expected $tmpFileName as fileName", tmpFileName, pageResults.pageFileName )
TestCase.assertEquals("expected $tmpFileName as fileName", tmpFileName, pageResults.pageFileName )
}


Expand All @@ -69,9 +70,9 @@ class AllChecksRunnerTest extends GroovyTestCase {
SinglePageResults pageResults = allChecksRunner.performChecksForOneFile( tmpFile )

int expected = AllCheckers.checkerClazzes.size()
assertEquals("expected $expected kinds of checks", expected, pageResults.singleCheckResults.size())
TestCase.assertEquals("expected $expected kinds of checks", expected, pageResults.singleCheckResults.size())

assertEquals("expected 2 findings", 2, pageResults.nrOfFindingsOnPage())
TestCase.assertEquals("expected 2 findings", 2, pageResults.nrOfFindingsOnPage())

}

Expand All @@ -86,7 +87,7 @@ class AllChecksRunnerTest extends GroovyTestCase {
allChecksRunner = new AllChecksRunner(myConfig)
SinglePageResults pageResults = allChecksRunner.performChecksForOneFile(tmpFile)

assertEquals(1, pageResults.singleCheckResults.size())
TestCase.assertEquals(1, pageResults.singleCheckResults.size())
}

}
Expand Down
33 changes: 2 additions & 31 deletions htmlSanityCheck-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@ dependencies {
'junit:junit:4.12',
'org.spockframework:spock-core:1.3-groovy-2.5')

implementation gradleApi()

implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.1'

// since gradle 4.6, annotation processors shall be explicitly declared
// (instead of just having them in the compile-group)
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.17.1'


// jsoup is our awesome html parser, see jsoup.org
implementation group: 'org.jsoup', name: 'jsoup', version: '1.16.1'

implementation gradleApi()

implementation project(":htmlSanityCheck-core")
} // dependencies


Expand All @@ -55,7 +47,6 @@ ext {

// tag::BuildPlugins[]
apply plugin: 'groovy'
apply plugin: 'java'

apply plugin: 'java-gradle-plugin'

Expand All @@ -75,26 +66,6 @@ apply from: "../config/publish-snapshot.gradle"
// end:BuildPlugins[]


task copyResourceImages(type: Copy) {
from('src/main/resources') {
include '**/*.png'
}
into processResources.destinationDir
}

processResources {
exclude '**/*.png'
inputs.property "version", project.version
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [version: project.version])
dependsOn copyResourceImages
println "after processResources config, version= ${project.version}"
}

// ========================================================




// ==========================================================
// if you use htmlSanityCheck locally, publish with
// "gradle publishToMavenLocal"
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ plugins {

rootProject.name = 'htmlSanityCheck'

include ':htmlSanityCheck-core',
':htmlSanityCheck-gradle-plugin'
include 'htmlSanityCheck-core',
'htmlSanityCheck-gradle-plugin'
6 changes: 3 additions & 3 deletions src/docs/arc42/chapters/_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

:project: htmlsanitycheck

// where are images located?
// where are the images located?
ifndef::imagesdir[:imagesdir: ../images]

:project: htmlSanityCheck
Expand All @@ -23,8 +23,8 @@ ifndef::imagesdir[:imagesdir: ../images]
:project-repository-docs-link: https://github.com/aim42/htmlSanityCheck/blob/main/src/docs/
:project-repository-docs-edit-link: https://github.com/aim42/htmlSanityCheck/edit/main/src/docs/

:coresourcepath: {projectRootDir}/src/main/groovy/org/aim42
:coretestpath: {projectRootDir}/src/test/groovy/org/aim42
:coresourcepath: {projectRootDir}/htmlSanityCheck-core/src/main/groovy/org/aim42
:coretestpath: {projectRootDir}/htmlSanityCheck-core/src/test/groovy/org/aim42

:asciidoctor-gradle-plugin-url: https://github.com/asciidoctor/asciidoctor-gradle-plugin

Expand Down

0 comments on commit ce36f41

Please sign in to comment.