Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shade and rewrite codehaus and maven dependencies #2115

Closed

Conversation

jurgenvinju
Copy link
Member

@jurgenvinju jurgenvinju commented Jan 3, 2025

  • by relocating org.apache.maven and org.codehaus we can run maven instance classes twice without collision later in the rascal-maven-plugin
  • removed the unshaded deployment profile
  • removed the appenders for maven/codehaus dependency injection files, because the relocator will produce two different files now.

@jurgenvinju
Copy link
Member Author

jurgenvinju commented Jan 3, 2025

  • tested java -jar rascal.jar; import util::Reflective; getRascalProjectConfig(|project://rascal|)
  • tested mvn rascal:console; import util::Reflective; getRascalProjectConfig(|project://rascal|)
    • snapshot dependency on this PR rascal branch

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49%. Comparing base (6c58baa) to head (6016e9e).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2115   +/-   ##
=======================================
  Coverage       49%     49%           
- Complexity    6224    6234   +10     
=======================================
  Files          663     663           
  Lines        59181   59181           
  Branches      8615    8615           
=======================================
+ Hits         29458   29479   +21     
+ Misses       27497   27475   -22     
- Partials      2226    2227    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jurgenvinju jurgenvinju self-assigned this Jan 3, 2025
@DavyLandman
Copy link
Member

I like this better, but we should also revert the changes to build.yaml

@@ -322,14 +322,6 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>io/usethesource/vallang/type/types.config</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did hmyhey get removed? Shouldn't they still be there, but in a new directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to remove them for the sake of minimalism. That worked. I guess the rewrites make sure the collisions don't happen anymore.

@DavyLandman
Copy link
Member

We should also do a test of the generated jar on Windows, just to make sure it also works there.

@jurgenvinju
Copy link
Member Author

Ok. Are there any volunteers for testing the jar on windows? I had to remove my virtual windows 10 to save disk space.

Removed unshaded action run
@DavyLandman
Copy link
Member

On Monday I'll bake a jar and run it.

@DavyLandman
Copy link
Member

DavyLandman commented Jan 6, 2025

On windows, it doesn't work:

rascal>getProjectPathConfig(|home:///swat.engineering/rascal/rascal-libs/salix-contrib/|);
WARNING: could not resolve dependency on: |lib://salix-core| because: |lib://salix-core|
PathConfig: pathConfig(
  ignores=[],
  javaCompilerPath=[|file:///C:/Users/Davy/swat.engineering/rascal/releng/rascal/target/rascal-0.41.0-RC3-SNAPSHOT.jar|],
  bin=|target://salix-contrib|,
  classloaders=[
    |target://salix-contrib|,
    |system:///|
  ],
  libs=[|lib://rascal|],
  srcs=[|home:///swat.engineering/rascal/rascal-libs/salix-contrib/src/main/rascal|])
rascal>

while it should have been (v0.40.17.jar):

rascal>getProjectPathConfig(|home:///swat.engineering/rascal/rascal-libs/salix-contrib/|);
PathConfig: pathConfig(
  ignores=[],
  javaCompilerPath=[|file:///C:/Users/Davy/.m2/repository/org/rascalmpl/rascal/0.40.17/rascal-0.40.17.jar|],
  bin=|target://salix-contrib|,
  classloaders=[
    |target://salix-contrib|,
    |system:///|,
    |file:///C:/Users/Davy/.m2/repository/org/rascalmpl/rascal/0.40.11/rascal-0.40.11.jar|,
    |file:///C:/Users/Davy/.m2/repository/org/rascalmpl/salix-core/0.2.5/salix-core-0.2.5.jar|
  ],
  libs=[
    |lib://rascal|,
    |jar+file:///C:/Users/Davy/.m2/repository/org/rascalmpl/salix-core/0.2.5/salix-core-0.2.5.jar!/|
  ],
  srcs=[|home:///swat.engineering/rascal/rascal-libs/salix-contrib/src/main/rascal|])

@DavyLandman
Copy link
Member

I've just tested it on linux, it also doesn't work.

rascal>getProjectPathConfig(|home:///swat.engineering/rascal/salix-contrib/|);
WARNING: could not resolve dependency on: |lib://salix-core| because: |lib://salix-core|
PathConfig: pathConfig(
  ignores=[],
  javaCompilerPath=[|file:///home/davy/swat.engineering/rascal/rascal/target/rascal-0.41.0-RC3-SNAPSHOT.jar|],
  bin=|target://salix-contrib|,
  classloaders=[
    |target://salix-contrib|,
    |system:///|
  ],
  libs=[|lib://rascal|],
  srcs=[|home:///swat.engineering/rascal/salix-contrib/src/main/rascal|])

Copy link
Member

@DavyLandman DavyLandman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It breaks the behavior of the maven project resolution. All you get is the fallback behavior of an empty path config with some defaults filled in from the project and rascal.mf.

(revering the file merging config back to the original has no effect)

@DavyLandman
Copy link
Member

It's caused by the logging framework, that tries to (via reflection) load the log class, but that class doesn't exist anymore, as it's been relocated.

java.lang.ClassNotFoundException: org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at org.rascalmpl.apache.maven.cli.logging.Slf4jConfigurationFactory.getConfiguration(Slf4jConfigurationFactory.java:61)
        at org.rascalmpl.apache.maven.cli.MavenCli.logging(MavenCli.java:488)
        at org.rascalmpl.apache.maven.cli.MavenCli.doMain(MavenCli.java:274)
        at org.rascalmpl.library.util.Maven.runCommand(Maven.java:55)
        at org.rascalmpl.library.util.Maven.runCommand(Maven.java:72)
        at org.rascalmpl.library.util.PathConfig.getPomXmlCompilerClasspath(PathConfig.java:640)
        at org.rascalmpl.library.util.PathConfig.fromSourceProjectRascalManifest(PathConfig.java:475)
        at org.rascalmpl.shell.ShellEvaluatorFactory.configureProjectEvaluator(ShellEvaluatorFactory.java:72)
        at org.rascalmpl.shell.ShellEvaluatorFactory.getDefaultEvaluator(ShellEvaluatorFactory.java:42)
        at org.rascalmpl.shell.REPLRunner$1.constructEvaluator(REPLRunner.java:51)
        at org.rascalmpl.repl.RascalInterpreterREPL.initialize(RascalInterpreterREPL.java:76)
        at org.rascalmpl.repl.BaseREPL.initialize(BaseREPL.java:158)
        at org.rascalmpl.repl.BaseREPL.<init>(BaseREPL.java:112)
        at org.rascalmpl.repl.BaseREPL.<init>(BaseREPL.java:61)
        at org.rascalmpl.shell.REPLRunner.<init>(REPLRunner.java:36)
        at org.rascalmpl.shell.RascalShell.main(RascalShell.java:80)
[main] WARN org.rascalmpl.apache.maven.cli.logging.impl.UnsupportedSlf4jBindingConfiguration - The SLF4J binding actually used is not supported by Maven: org.slf4j.impl.SimpleLoggerFactory
[main] WARN org.rascalmpl.apache.maven.cli.logging.impl.UnsupportedSlf4jBindingConfiguration - Maven supported bindings are:
[main] ERROR org.rascalmpl.apache.maven.cli.MavenCli - Error executing Maven.
[main] ERROR org.rascalmpl.apache.maven.cli.MavenCli - java.util.NoSuchElementException
      role: org.rascalmpl.apache.maven.eventspy.internal.EventSpyDispatcher
  roleHint:
[main] ERROR org.rascalmpl.apache.maven.cli.MavenCli - Caused by: null
java.lang.ClassNotFoundException: org.apache.maven.cli.logging.impl.Slf4jSimpleConfiguration
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:315)
        at org.rascalmpl.apache.maven.cli.logging.Slf4jConfigurationFactory.getConfiguration(Slf4jConfigurationFactory.java:61)
        at org.rascalmpl.apache.maven.cli.MavenCli.logging(MavenCli.java:488)
        at org.rascalmpl.apache.maven.cli.MavenCli.doMain(MavenCli.java:274)
        at org.rascalmpl.library.util.Maven.runCommand(Maven.java:55)
        at org.rascalmpl.library.util.PathConfig.getPomXmlCompilerClasspath(PathConfig.java:644)
        at org.rascalmpl.library.util.PathConfig.fromSourceProjectRascalManifest(PathConfig.java:475)
        at org.rascalmpl.shell.ShellEvaluatorFactory.configureProjectEvaluator(ShellEvaluatorFactory.java:72)
        at org.rascalmpl.shell.ShellEvaluatorFactory.getDefaultEvaluator(ShellEvaluatorFactory.java:42)
        at org.rascalmpl.shell.REPLRunner$1.constructEvaluator(REPLRunner.java:51)
        at org.rascalmpl.repl.RascalInterpreterREPL.initialize(RascalInterpreterREPL.java:76)
        at org.rascalmpl.repl.BaseREPL.initialize(BaseREPL.java:158)
        at org.rascalmpl.repl.BaseREPL.<init>(BaseREPL.java:112)
        at org.rascalmpl.repl.BaseREPL.<init>(BaseREPL.java:61)
        at org.rascalmpl.shell.REPLRunner.<init>(REPLRunner.java:36)
        at org.rascalmpl.shell.RascalShell.main(RascalShell.java:80)

@DavyLandman
Copy link
Member

I've fix this in a different way. Namely properly pubishing a rascal-unshaded next to rascal. We wanted to try and do this purely via the shade plugin, but that would have never worked.

So I propose we abandon this PR?

@jurgenvinju jurgenvinju closed this Jan 7, 2025
@jurgenvinju jurgenvinju deleted the shade-and-rewrite-codehaus-and-maven-dependencies branch January 7, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants