Giter Site home page Giter Site logo

Execution add-module-infos of goal org.moditect:moditect-maven-plugin:1.2.1.Final:add-module-info failed: Encountered unexpected token: "-" "-" about moditect HOT 11 OPEN

garydgregory avatar garydgregory commented on September 7, 2024
Execution add-module-infos of goal org.moditect:moditect-maven-plugin:1.2.1.Final:add-module-info failed: Encountered unexpected token: "-" "-"

from moditect.

Comments (11)

aalmiray avatar aalmiray commented on September 7, 2024

Please post the contents of /Users/garydgregory/git/commons-beanutils-1/target/moditect/commons.beanutils/versions/9/module-info.java

from moditect.

garydgregory avatar garydgregory commented on September 7, 2024

That file is generated by the build when you run mvn (notice that it's in the target directory):

cat target/moditect/commons.beanutils/versions/9/module-info.java

says:

module commons.beanutils {
    requires commons.logging;

    requires transitive commons.collections;
    requires transitive java.desktop;
    requires transitive java.sql;

    exports org.apache.commons.beanutils;
    exports org.apache.commons.beanutils.converters;
    exports org.apache.commons.beanutils.expression;
    exports org.apache.commons.beanutils.locale;
    exports org.apache.commons.beanutils.locale.converters;

}

from moditect.

aalmiray avatar aalmiray commented on September 7, 2024

Indeed. This is the file that javaparser is chocking on at the moment.

from moditect.

garydgregory avatar garydgregory commented on September 7, 2024

Hm, ok, now what?

from moditect.

aalmiray avatar aalmiray commented on September 7, 2024

There's something odd with the modiTect setup. As far as I can tell from commons-parent:69 the module name is defined by an expresion ${commons.module.name}

https://github.com/apache/commons-parent/blob/e562e692afef1f6d28cfdd30cd6854c27dba189a/pom.xml#L1839-L1844

https://github.com/apache/commons-parent/blob/e562e692afef1f6d28cfdd30cd6854c27dba189a/pom.xml#L253-L256

Which should make that expression evaluate to org.apache.commons.commons-beanutils and used as input for modiTect. However, the generated module descriptor uses commons.beanutils instead. Now, java parser chokes because it found a "-" character, which so happens to be the hyphen in commons-beanutils.

Explicitly defining a value for commons.module.name such as

<commons.module.name>org.apache.commons.commons.beanutils</commons.module.name>

Makes the build work. So, now the question is: why is the the generated module name common.beanutils and not org.apache.commons.commons-beanutils?

Update: as far as I recall "-" is an invalid character for a JPMS module.

from moditect.

aalmiray avatar aalmiray commented on September 7, 2024

Running the build with -X shows the inputs sent to modiTect

[DEBUG] Loading mojo org.moditect:moditect-maven-plugin:1.2.1.Final:add-module-info from plugin realm ClassRealm[plugin>org.moditect:moditect-maven-plugin:1.2.1.Final, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@3d71d552]
[DEBUG] Configuring mojo execution 'org.moditect:moditect-maven-plugin:1.2.1.Final:add-module-info:add-module-infos' with basic configurator -->
[DEBUG]   (f) artifactId = commons-beanutils
[DEBUG]   (f) buildDirectory = /tmp/commons-beanutils/target
[DEBUG]   (f) failOnWarning = false
[DEBUG]   (f) jdepsExtraArgs = [--multi-release=9]
[DEBUG]   (f) jvmVersion = 9
[DEBUG]   (s) name = org.apache.commons.commons-beanutils
[DEBUG]   (s) addServiceUses = true
[DEBUG]   (s) moduleInfo = ModuleInfoConfiguration [requires=*;, exports=*;, opens=!*;, opensResources=null, uses=null, provides=null, name=org.apache.commons.commons-beanutils, addServiceUses=true, open=false]
[DEBUG]   (f) module = MainModuleConfiguration [ moduleInfo=ModuleInfoConfiguration [requires=*;, exports=*;, opens=!*;, opensResources=null, uses=null, provides=null, name=org.apache.commons.commons-beanutils, addServiceUses=true, open=false], moduleInfoFile=null, moduleInfoSource=null, mainClass=null]
[DEBUG]   (f) outputDirectory = /tmp/commons-beanutils/target
[DEBUG]   (f) outputTimestamp = 2024-01-01T00:00:00Z
[DEBUG]   (f) overwriteExistingFiles = true
[DEBUG]   (f) project = MavenProject: commons-beanutils:commons-beanutils:1.9.5 @ /tmp/commons-beanutils/pom.xml
[DEBUG]   (f) remoteRepos = [apache.snapshots (https://repository.apache.org/snapshots, default, snapshots), central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG]   (f) repoSession = org.eclipse.aether.DefaultRepositorySystemSession@10fcc44b
[DEBUG]   (f) skip = false
[DEBUG]   (f) version = 1.9.5
[DEBUG]   (f) workingDirectory = /tmp/commons-beanutils/target/moditect
[DEBUG] -- end configuration --

Clearly showing the problematic input as

[DEBUG]   (s) name = org.apache.commons.commons-beanutils

from moditect.

aalmiray avatar aalmiray commented on September 7, 2024

Aaand I'm an idiot. The generated module-info.java file was created using jdeps which takes the module name from the filename. So it's OK. The actual generated module-info.class looks like this

$ jarviz module descriptor --file target/commons-beanutils-1.9.5-SNAPSHOT.jar 
subject: commons-beanutils-1.9.5-SNAPSHOT.jar
name: org.apache.commons.commons.beanutils
version: 1.9.5-SNAPSHOT
open: false
automatic: false
exports:
  org.apache.commons.beanutils
  org.apache.commons.beanutils.converters
  org.apache.commons.beanutils.expression
  org.apache.commons.beanutils.locale
  org.apache.commons.beanutils.locale.converters
requires:
  commons.collections
  commons.logging
  java.base mandated
  java.desktop
  java.sql

from moditect.

garydgregory avatar garydgregory commented on September 7, 2024

Ah! This makes sense now, we must have commons.module.name defined. We must give Moditect a reasonable value, and in this case, the one we built by default was bad. TY!

from moditect.

aalmiray avatar aalmiray commented on September 7, 2024

Here's the thing, modiTect could either:

  1. Warn if the proposed module name is invalid and bail out
  2. Transform the proposed module name to a valid one (when possible), bailing out if unsuccessful

The current error is accurate but cryptic.

@gunnarmorling WDYT?

from moditect.

garydgregory avatar garydgregory commented on September 7, 2024

I don't think a hidden transformation is OK. Especially if I can't turn it off. I don't want to be in the position of publishing a surprising and unintentionally wrong name.

from moditect.

garydgregory avatar garydgregory commented on September 7, 2024

A better error message is welcome of course.

from moditect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.