jruby / jruby-maven-plugins

maven plugin to handle rubygems in a maven way. including support for rspec, rails, cucumber, rake, etc
MIT License
112 stars 46 forks source link

gem-install-plugin installs invalid pom.xmls on Java11 #92

Closed robertpanzer closed 5 years ago

robertpanzer commented 5 years ago

To reproduce create an empty directory and add this file pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>rubygems</groupId>
    <artifactId>asciidoctor</artifactId>
    <version>2.0.0.dev-SNAPSHOT</version>
    <packaging>gem</packaging>
    <name>Asciidoctor RubyGem Installer</name>
    <description>Installs the upstream Asciidoctor RubyGem to the local repository.</description>
    <url>http://asciidoctor.org</url>
    <repositories>
        <repository>
            <id>rubygems-releases</id>
            <url>http://rubygems-proxy.torquebox.org/releases</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>rubygems-releases</id>
            <url>http://rubygems-proxy.torquebox.org/releases</url>
        </pluginRepository>
    </pluginRepositories>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>de.saumya.mojo</groupId>
                <artifactId>gem-maven-plugin</artifactId>
                <version>1.1.5</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

Then create this file test.sh:

#!/bin/bash

rm -rf asciidoctor-master

wget --quiet -O $SRC_DIR.zip https://github.com/asciidoctor/asciidoctor/archive/master.zip
unzip -q $SRC_DIR.zip

cp pom.xml asciidoctor-master/
cd asciidoctor-master

mvn install -Dgemspec=asciidoctor.gemspec -Djruby.version=9.2.4.0 -Djruby.jvmargs="-XX:+IgnoreUnrecognizedVMOptions --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED"

When running this on Java 11 (and I guess this started from Java 9), the pom.xml that is installed into the local maven cache starts with the Java warning for illegal access:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.util.SecurityHelper to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of org.jruby.util.SecurityHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>rubygems</groupId>
  <artifactId>asciidoctor</artifactId>
  <version>2.0.0.dev-SNAPSHOT</version>
  <packaging>gem</packaging>
  <name>An implementation of the AsciiDoc text processor and publishing toolchain in Ruby</name>
  <url>http://asciidoctor.org</url>
  <description>A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML5, DocBook 5 (or 4.5) and other formats.</description>
  <licenses>
    <license>
      <name>MIT</name>
      <url>http://opensource.org/licenses/MIT</url>
      <comments>MIT license</comments>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Dan Allen</name>
      <email>dan.j.allen@gmail.com</email>
    </developer>
    <developer>
      <name>Sarah White</name>
    </developer>
    <developer>
      <name>Ryan Waldron</name>
    </developer>
    <developer>
      <name>Jason Porter</name>
    </developer>
    <developer>
      <name>Nick Hengeveld</name>
    </developer>
    <developer>
      <name>Jeremy McAnally</name>
    </developer>
  </developers>
  <properties>
    <project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
    <jruby.plugins.version>1.0.9</jruby.plugins.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>asciimath</artifactId>
      <version>[1.0.0,1.0.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>coderay</artifactId>
      <version>[1.1.0,1.1.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>cucumber</artifactId>
      <version>[2.4.0,2.4.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>erubis</artifactId>
      <version>[2.7.0,2.7.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>haml</artifactId>
      <version>[5.0.0,5.0.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>nokogiri</artifactId>
      <version>[1.8.5,1.8.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>rake</artifactId>
      <version>[10.0.0,10.0.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>rspec-expectations</artifactId>
      <version>[2.14.0,2.14.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>slim</artifactId>
      <version>[4.0.0,4.0.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>tilt</artifactId>
      <version>[2.0.0,2.0.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>minitest</artifactId>
      <version>[5.3.0,5.3.99999]</version>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <id>rubygems-releases</id>
      <url>http://rubygems-proxy.torquebox.org/releases</url>
    </repository>
  </repositories>
  <build>
    <extensions>
      <extension>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>gem-extension</artifactId>
        <version>${jruby.plugins.version}</version>
      </extension>
    </extensions>
    <directory>${basedir}/pkg</directory>
    <plugins>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>gem-maven-plugin</artifactId>
        <version>${jruby.plugins.version}</version>
        <configuration>
          <gemspec>asciidoctor.gemspec</gemspec>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

The Warnings at the beginning of the file make it unusable.

mkristian commented 5 years ago

FYI @robertpanzer try to get a fix released this week

robertpanzer commented 5 years ago

Even with 1.1.6 it still seems to write additional content into the generated pom.xml. On Travis I get a pom that starts like this:

Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>rubygems</groupId>
...
robertpanzer commented 5 years ago

@mkristian Do you already have an idea what could have gone wrong? Or is there something that I could look at?

mkristian commented 5 years ago

@robertpanzer I always think during the weekend I will find time for these things but I do not. so first a big sorry for being so slow in responding. things are probably not so bad, under the hood an ant task is used and error stream can be controlled to some extend: https://github.com/torquebox/jruby-maven-plugins/blob/master/ruby-tools/src/main/java/de/saumya/mojo/ruby/script/AntLauncher.java

testing is a different thing - the first report of yours I was able to reproduce locally not sure about the travis error you see.

robertpanzer commented 5 years ago

No worries, I know this feeling all too well! :D If the jruby-maven-plugin would be working again, there would indeed be no point in using gradle for this task. This issue just prevents us from testing AsciidoctorJ against the upstream version of Asciidoctor.

If there's any way how I could help out, just let me know.

mkristian commented 5 years ago

@robertpanzer what would I need to do to trigger the travis build ? a PR from master using a snapshot for the maven-plugin ?

robertpanzer commented 5 years ago

If you create a PR against AsciidoctorJ it should run test upstream test against Java 11, and only with Java 11. The version of the jruby-maven-plugin is configured in https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctor-gem-installer.pom. Travis will first build against the last released version. When that build has passed, it will run the script https://github.com/asciidoctor/asciidoctorj/blob/master/test-asciidoctor-upstream.sh that tries to test against the latest dev version of asciidoctor, i.e. 2.0.0-dev. The test itself is expected to fail due to some incompatible changes, but currently it doesn't accept the pom generated by the ruby-maven-plugin due to the additional content.

So to test it yourself on Travis, just create a PR for AsciidoctorJ and check the Java11 build on Travis.

mkristian commented 5 years ago

@robertpanzer this looks like it went further and created a working pom: https://travis-ci.org/asciidoctor/asciidoctorj/jobs/498048587 if this is the case I will clean up the patch and release the plugin and finalize the PR

robertpanzer commented 5 years ago

Thanks! That's fantastic. The build failed now, but these are exactly the errors that we want to catch in with the upstream build. It would be great if you could make a new release and finalize the PR.

Thanks a lot again!

kares commented 5 years ago

there's some snapshots being pushed, if it was done on a dirty branch we could try looking into it as well

mkristian commented 5 years ago

done