Giter Site home page Giter Site logo

Java 9 support about code-assert HOT 7 OPEN

nidi3 avatar nidi3 commented on June 5, 2024 2
Java 9 support

from code-assert.

Comments (7)

nidi3 avatar nidi3 commented on June 5, 2024 3

released as 0.9.12

from code-assert.

nidi3 avatar nidi3 commented on June 5, 2024 1

Sorry for the long delay.
I merged your PR, thanks for it. There will be a release shortly.

from code-assert.

nidi3 avatar nidi3 commented on June 5, 2024 1

Yes, it's added.

from code-assert.

dbwiddis avatar dbwiddis commented on June 5, 2024

This project is presently impossible to include in a Java 9+ project using JPMS. In order to include it, one has to enter a requires modluename in their module-info file.

This project has not configured any module name, so Java 9+ is falling back to an automatic method of determining the module name, which uses the jar file name, minus the version information. Hyphens are disallowed as characters in module names, so a dot is substituted, creating the automatic module name code.assert.

Unfortunately, assert is a reserved word in Java and thus not possible to include in a module name, so it is impossible to include code-assert as a required dependency. I am forced to either not use modules, or not use code-assert.

Providing module support to Java 9+ without implementing modules yourself is trivial if you use Maven as a build system. Simply add this to your parent pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <archive>
        <manifestEntries>
          <Automatic-Module-Name>${autoModuleName}</Automatic-Module-Name>
        </manifestEntries>
      </archive>
    </configuration>
  </plugin>

And then in each of your modules, define that property, e.g., <autoModuleName>guru.nidi.codeassert<autoModuleName>

See this blog post for more details and reasoning why library maintainers should do this.

from code-assert.

dbwiddis avatar dbwiddis commented on June 5, 2024

Any chance you can look into merging #40? Presently the lack of a legal module name is a blocker for using code-assert with JDK 9+.

from code-assert.

dbwiddis avatar dbwiddis commented on June 5, 2024

Thanks! Before you release I hope you can test with mvn jar:jar and inspect the META-INF/MANIFEST.MF file to make sure the auto name got added. If not I might need to fix that configuration.

from code-assert.

dbwiddis avatar dbwiddis commented on June 5, 2024

FYI, I have been struggling to include code-assert in a modular build. There are two unique issues:

  • There is a transitive dependency (via pmd) to javacc which is incompatible:
[ERROR] java.lang.module.FindException: Unable to derive module descriptor for /Users/danielwiddis/.m2/repository/net/java/dev/javacc/javacc/5.0/javacc-5.0.jar
[ERROR] Caused by: java.lang.module.InvalidModuleDescriptorException: jjdoc.class found in top-level directory (unnamed package not allowed in module)
  • There is a split package issue from hamcrest library modules.
[ERROR] java.lang.module.ResolutionException: Modules hamcrest.core and org.hamcrest export package org.hamcrest.internal to module junit

I was able to resolve that by changing my own dependency to the hamcrest-core artifact rather than hamcrest.

For the javacc error I've tried using exclusions to tweak things:

		<dependency>
			<groupId>guru.nidi</groupId>
			<artifactId>code-assert</artifactId>
			<version>${code-assert.version}</version>
			<scope>test</scope>
			<exclusions>
				<!-- pmd dependency has class in unnamed package -->
				<exclusion>
					<groupId>net.java.dev.javacc</groupId>
					<artifactId>javacc</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

but that now gives me a split package:

[ERROR] java.lang.module.ResolutionException: Modules pmd.java and pmd.core export package net.sourceforge.pmd.cpd to module saxon

I'm sure there's more I could do playing with exclusions here, but I'm getting out of my depth knowing all the code assert dependencies.

Not really a new problem or new solution but sharing progress in case anyone else is going down this road. I do think updating code assert to the latest version of most dependencies might clean a few things up.

from code-assert.

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.