Skip to content

Commit

Permalink
Issue #417: BOM should not inherit build setup from parent POM
Browse files Browse the repository at this point in the history
- Need to use UIMA Maven plugins from last release cycle, otherwise build fails
- Fix small formatting issue in documentation
  • Loading branch information
reckart committed Nov 20, 2024
1 parent 7016463 commit dc6ce26
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,80 +19,58 @@
package org.apache.uima.tools.jcasgen.maven;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;

import org.apache.maven.plugin.testing.MojoRule;
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.RepositorySystemSession;
import org.junit.Rule;
import org.junit.Test;

public class JCasGenMojoTest extends AbstractMojoTestCase {
public class JCasGenMojoTest {

public @Rule MojoRule rule = new MojoRule();

@Test
public void testInvalidFeature() throws Exception {
Exception ee = null;
try {
assertThatExceptionOfType(Exception.class).isThrownBy(() -> {
this.test("invalidFeature");
} catch (Exception e) {
ee = e;
}
assertTrue(ee != null);
assertEquals(
"JCasGen: The feature name 'type', specified in Type 'type.span.Sentence' is reserved. Please choose another name.",
ee.getMessage());
}).withMessage(
"JCasGen: The feature name 'type', specified in Type 'type.span.Sentence' is reserved. Please choose another name.");
}

@Test
public void testSimple() throws Exception {
this.test("simple", "type.span.Sentence", "type.span.Token", "type.relation.Dependency");
test("simple", "type.span.Sentence", "type.span.Token", "type.relation.Dependency");
}

@Test
public void testClasspath() throws Exception {
this.test("classpath", "type.span.Sentence", "type.span.Token", "type.relation.Dependency");
test("classpath", "type.span.Sentence", "type.span.Token", "type.relation.Dependency");
}

@Test
public void testWildcard() throws Exception {
this.test("wildcard", "type.span.Sentence", "type.span.Token");
test("wildcard", "type.span.Sentence", "type.span.Token");
}

@Test
public void testExclude() throws Exception {
this.test("exclude", "type.span.Sentence");
test("exclude", "type.span.Sentence");
}

@Test
public void test(String projectName, String... types) throws Exception {
private void test(String projectName, String... types) throws Exception {

File projectSourceDirectory = getTestFile("src/test/resources/" + projectName);
File projectDirectory = getTestFile("target/project-" + projectName + "-test");
var projectSourceDirectory = new File("src/test/resources/" + projectName);
var projectDirectory = new File("target/project-" + projectName + "-test");

// Stage project to target folder
FileUtils.copyDirectoryStructure(projectSourceDirectory, projectDirectory);

File pomFile = new File(projectDirectory, "/pom.xml");
assertNotNull(pomFile);
assertTrue(pomFile.exists());

// create the MavenProject from the pom.xml file
RepositorySystemSession session = MavenRepositorySystemUtils.newSession();
MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
buildingRequest.setRepositorySession(session);
ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class);
MavenProject project = projectBuilder.build(pomFile, buildingRequest).getProject();
assertNotNull(project);
var project = rule.readMavenProject(projectDirectory);

// copy resources
File source = new File(projectDirectory, "src/main/resources");
Expand All @@ -101,11 +79,11 @@ public void test(String projectName, String... types) throws Exception {
}

// load the Mojo
JCasGenMojo generate = (JCasGenMojo) this.lookupConfiguredMojo(project, "generate");
assertNotNull(generate);
var generate = (JCasGenMojo) rule.lookupConfiguredMojo(project, "generate");
assertThat(generate).isNotNull();

// set the MavenProject on the Mojo (AbstractMojoTestCase does not do this by default)
setVariableValueToObject(generate, "project", project);
rule.setVariableValueToObject(generate, "project", project);

// execute the Mojo
generate.execute();
Expand All @@ -114,17 +92,18 @@ public void test(String projectName, String... types) throws Exception {
File jCasGenDirectory = new File(project.getBasedir(), "target/generated-sources/jcasgen");

// Record all the files that were generated
DirectoryScanner ds = new DirectoryScanner();
var ds = new DirectoryScanner();
ds.setBasedir(jCasGenDirectory);
ds.setIncludes(new String[] { "**/*.java" });
ds.scan();
List<File> files = new ArrayList<>();
for (String scannedFile : ds.getIncludedFiles()) {

var files = new ArrayList<File>();
for (var scannedFile : ds.getIncludedFiles()) {
files.add(new File(ds.getBasedir(), scannedFile));
}

for (String type : types) {
File wrapperFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + ".java");
for (var type : types) {
var wrapperFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + ".java");
// no _type files in v3
// File typeFile = new File(jCasGenDirectory + "/" + type.replace('.', '/') + "_Type.java");

Expand Down
96 changes: 30 additions & 66 deletions uimaj-documentation/src/docs/asciidoc/ref/ref.config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,36 @@ It causes the framework to throw a UIMARuntimeException if an update outside of

This table describes the various JVM defined properties; specify these on the Java command line using -Dxxxxxx, where the xxxxxx is one of the properties starting with `uima.` from the table below.

.General properties
[cols="1,1,1", frame="all"]
|===

|**Title**
|**Property Name & Description**
|**Since Version**

|

Use built-in Java Logger as default back-end
|

`uima.use_jul_as_default_uima_logger`
| Use built-in Java Logger as default back-end
| `uima.use_jul_as_default_uima_logger`

See https://issues.apache.org/jira/browse/UIMA-5381[UIMA-5381].
The standard UIMA logger uses an slf4j implementation, which, in turn hooks up to a back end implementation based on what can be found in the class path (see slf4j documentation). If no backend implementation is found, the slf4j default is to use a NOP logger back end which discards all logging.

When this flag is specified, the behavior of the UIMA logger is altered to use the built-in-to-Java logging implementation as the back end for the UIMA logger.
|

3.0.0

|
| 3.0.0

XML: enable doctype declarations
|

`uima.xml.enable.doctype_decl` (default is false)
| XML: enable doctype declarations
| `uima.xml.enable.doctype_decl` (default is false)

See https://issues.apache.org/jira/browse/UIMA-6064[UIMA-6064] Normally, this is turned off to avoid exposure to malicious XML; see https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing[
XML External Entity processing vulnerability].
|

2.10.4, 3.1.0

|**Index protection properties**

|

Report Illegal Index-key Feature Updates
|
| 2.10.4, 3.1.0
|===

`uima.report_fs_update_corrupts_index` (default is not to report)
.Index protection properties
[cols="1,1,1", frame="all"]
|===
| Report Illegal Index-key Feature Updates
| `uima.report_fs_update_corrupts_index` (default is not to report)

See https://issues.apache.org/jira/browse/UIMA-4135[UIMA-4135].
Updating Features which are used in Set and Sorted indexes as "keys" may corrupt the indexes, if the Feature Structure (FS) has been added to the indexes.
Expand All @@ -107,73 +94,50 @@ To scan the logs for these reports, search for instances of lines having the str
Specifying this property overrides ``uima.disable_auto_protect_indexes``.

Users would run with this property defined, and then for high performance, would use the report to manually change their code to avoid the problem or to wrap the updates with a `protectIndexes` kind of protection (see the reference manual, in the CAS or JCas chapters, for examples of user code doing this, and then run with the protection turned off (see below).
|

2.7.0

|
| 2.7.0

Throw exception on illegal Index-key Feature Updates
|

`uima.exception_when_fs_update_corrupts_index` (default is false)
| Throw exception on illegal Index-key Feature Updates
| `uima.exception_when_fs_update_corrupts_index` (default is false)

See https://issues.apache.org/jira/browse/UIMA-4150[UIMA-4150].
Throws a UIMARuntimeException if an Indexed FS feature used as a key in one or more indexes is updated, outside of an explicit `protectIndexes` block.. \ This is intended for use in automated build and test environments, to provide a strong signal if this kind of mistake gets into the build.
If it is not set, then the other properties specify if corruption should be checked for, recovered automatically, and / or reported

Specifying this property also forces `uima.report_fs_update_corrupts_index` to true even if it was set to false.
|

2.7.0

|

Disable the index corruption checking
|
| 2.7.0

`uima.disable_auto_protect_indexes`
| Disable the index corruption checking
| `uima.disable_auto_protect_indexes`

See https://issues.apache.org/jira/browse/UIMA-4135[UIMA-4135].
After you have fixed all reported issues identified with the above report, you may set this property to omit this check, which may slightly improve performance.

Note that this property is ignored if the `-Dexception_when_fs_update_corrupts_index` or `-Dreport_fs_update_corrupts_index`
|

2.7.0

|**Measurement / Tracing properties**

|
| 2.7.0
|===

Trace Feature Structure Creation/Updating
|
.Measurement / Tracing properties
[cols="1,1,1", frame="all"]
|===

`uima.trace_fs_creation_and_updating`
| Trace Feature Structure Creation/Updating
| `uima.trace_fs_creation_and_updating`

This causes a trace file to be produced in the current working directory.
The file has one line for each Feature Structure that is created, and include information on the cas/cas-view, and the features that are set for the Feature Structure.
There is, additionally, one line for each Feature Structure update.
Updates that occur next-to trace information for the same Feature Structure are combined.

This can generate a lot of output, and definitely slows down execution.
|

2.10.1
| 2.10.1

|

Measure index flattening optimization
|

`uima.measure.flatten_index`
| Measure index flattening optimization
| `uima.measure.flatten_index`

See https://issues.apache.org/jira/browse/UIMA-4357[UIMA-4357].
This creates a short report to System.out when Java is shutdown.
The report has some statistics about the automatic management of flattened index creation and use.
|

2.8.0
| 2.8.0
|===

Some additional global flags intended for helping v3 migration are documented in the V3 user's guide.
4 changes: 1 addition & 3 deletions uimaj-it-pear-with-typesystem/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
<plugin>
<groupId>org.apache.uima</groupId>
<artifactId>PearPackagingMavenPlugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>package-pear</id>
Expand All @@ -111,8 +110,7 @@
<goal>package</goal>
</goals>
<configuration>
<mainComponentDesc>
desc/org/apache/uima/it/pear_with_typesystem/TestAnnotator.xml</mainComponentDesc>
<mainComponentDesc>desc/org/apache/uima/it/pear_with_typesystem/TestAnnotator.xml</mainComponentDesc>
<componentId>${project.artifactId}</componentId>
<datapath>$main_root/resources</datapath>
</configuration>
Expand Down
14 changes: 10 additions & 4 deletions uimaj-parent-internal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@

<eclipseP2RepoId>org.eclipse.p2.202209</eclipseP2RepoId>

<api_check_oldVersion>3.5.0</api_check_oldVersion>

<assemblySrcDescriptor>src/main/assembly/src.xml</assemblySrcDescriptor>

<!-- BEGIN PROFILE SETTINGS: generate-release-notes-->
<github-repository>uima-uimaj</github-repository>
<git-branch>main</git-branch>
<previous-release-version>3.5.0</previous-release-version>
<!-- END PROFILE SETTINGS: generate-release-notes-->

<api_check_oldVersion>${previous-release-version}</api_check_oldVersion>
<uima-maven-plugins-version>${previous-release-version}</uima-maven-plugins-version>
</properties>

<dependencies>
Expand Down Expand Up @@ -497,13 +498,18 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<javadocVersion>${maven.compiler.release}}</javadocVersion>
<javadocVersion>${maven.compiler.release}</javadocVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.uima</groupId>
<artifactId>jcasgen-maven-plugin</artifactId>
<version>${project.version}</version>
<version>${uima-maven-plugins-version}</version>
</plugin>
<plugin>
<groupId>org.apache.uima</groupId>
<artifactId>PearPackagingMavenPlugin</artifactId>
<version>${uima-maven-plugins-version}</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down

0 comments on commit dc6ce26

Please sign in to comment.