common-scanner

Provides scanner functionality for various

License

License

GroupId

GroupId

nz.ac.auckland.common
ArtifactId

ArtifactId

common-scanner
Last Version

Last Version

1.15
Release Date

Release Date

Type

Type

jar
Description

Description

common-scanner
Provides scanner functionality for various
Project URL

Project URL

https://github.com/uoa-group-applications/common-scanner
Source Code Management

Source Code Management

https://github.com/uoa-group-applications/common-scanner

Download common-scanner

How to add to project

<!-- https://jarcasting.com/artifacts/nz.ac.auckland.common/common-scanner/ -->
<dependency>
    <groupId>nz.ac.auckland.common</groupId>
    <artifactId>common-scanner</artifactId>
    <version>1.15</version>
</dependency>
// https://jarcasting.com/artifacts/nz.ac.auckland.common/common-scanner/
implementation 'nz.ac.auckland.common:common-scanner:1.15'
// https://jarcasting.com/artifacts/nz.ac.auckland.common/common-scanner/
implementation ("nz.ac.auckland.common:common-scanner:1.15")
'nz.ac.auckland.common:common-scanner:jar:1.15'
<dependency org="nz.ac.auckland.common" name="common-scanner" rev="1.15">
  <artifact name="common-scanner" type="jar" />
</dependency>
@Grapes(
@Grab(group='nz.ac.auckland.common', module='common-scanner', version='1.15')
)
libraryDependencies += "nz.ac.auckland.common" % "common-scanner" % "1.15"
[nz.ac.auckland.common/common-scanner "1.15"]

Dependencies

compile (1)

Group / Artifact Type Version
nz.ac.auckland.composite : composite-logging-api jar [3,)

provided (1)

Group / Artifact Type Version
nz.ac.auckland.composite : composite-groovy jar [5,)

test (2)

Group / Artifact Type Version
nz.ac.auckland.composite : composite-unittest jar [2,)
nz.ac.auckland.composite : composite-logging-deploy jar [3,)

Project Modules

There are no modules declared in this project.

common-scanner

This introduces a single class, MultiModuleConfigScanner - which looks through the URLClassPath and fires events based on the files it finds.

public interface Notifier {
  public void underlayWar(URL url) throws Exception;

  public void jar(URL url) throws Exception;

  public void dir(URL url) throws Exception;
}

Calling MultiModuleConfigScanner.scan - you provide an implementation of the notifier. It tells you when it finds

  • files ending in -underlay.war get passed to underlayWar()
  • files ending in .jar get passed to jar()
  • directories ending in X/target/classes get searched for X/src/main/resources and X/src/main/webapp. directories ending in X/target/test-classes gets examined for X/src/test/resources and X/src/test/webapp

Various applications (e.g. JAWR, Runnable War) use the scanner.

Configuration

The scanner also looks for configuration for the current project and injects it into the system properties if it finds a target/test-classes on the classpath. This is because we know we are running tests and are in the IDE or running Maven from the command line. It will for a Maven module called /fat-domain/target/test-classes determine that the Maven module is called fat-domain. We want to share properties across all of the Maven artifacts for fat (fat-admin, fat-albert, etc), it will then attemp to load:

/fat-domain/src/test/war.properties
~/.webdev/fat-domain/war.properties

~ refers to the System.getProperty("user.home") value.

If there is a line in either (or both) of these files called

scanner.commonConfigFiles=$home/fat.properties, /etc/fat/fat.properties

This will cause it to load like this (if this line is in /fat-domain/src/test/war.properties):

/fat-domain/src/test/war.properties      # module specific fat-domain ones that are common to everyone checking out the artifact
~/.webdev/fat.properties                 # fat common ones
/etc/fat/fat.properties                  # fat common ones
~/.webdev/fat-domain/war.properties      # module specific overriding all other properties (including "fat" common ones)

$home is replaced with the line:

 ~/.webdev

Unless the user specifies the system property "scanner.home" or an environment variable WAR_SCANNER_HOME

Overriding these is useful if you wish to store your configuration in (say) Dropbox or Google Drive or point it elsewhere for a test.

nz.ac.auckland.common

University of Auckland - Group Applications

MIT Licensed Java/Groovy libraries we use

Versions

Version
1.15
1.14