Migrate resources from src/main/java to src/main/resources

Description

Making a note of this here, as it was a new one for me:

  • IntelliJ marks folders as sources, generated sources, test sources, generated test sources, resources, test resources,

  • We have files such as gs-main src/test/java/org.vfny/geoserver/util/valid.sld that fail to load when running a test in InteliJ … because srs/test/java is a test resources folder and will not be scanned for resources!

  • this causes testValid() to fail, as null is returned (valid.sld cannot be found)

public void testValid() throws Exception { SLDValidator validator = new SLDValidator(); List errors = validator.validateSLD(getClass().getResourceAsStream("valid.sld")); // showErrors(errors); assertTrue(errors.isEmpty()); }

Wild :)

I think I have usually done a maven build first which copies such files to target/classes

References:

Environment

None

Activity

Jody Garnett 
April 18, 2022 at 7:14 AM

The “solution” is to migrate and non java files:

  • src/main/java → src/main/resources

  • src/test/java → src/test/resources

I cannot have been the first geoserver developer to find this out?

Details

Assignee

Reporter

Affects versions

Components

Priority

Created April 18, 2022 at 7:12 AM
Updated April 18, 2022 at 7:14 AM