Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-27451

All .properties files are being compiled by localizer, rather than just Messages.properties

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • gradle-jpi-plugin
    • None
    • Plugin 0.10.0

      I have a plugin where I have Jelly string resources in a description.properties file, e.g. similar to https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/model/Cause/UserIdCause/description.properties

      However, this cannot be compiled, as the generated Localizable class is created (in this case as description.java) with a package name that clashes with the source class name.

      :compileJava
      /home/.../foo-plugin/src/main/java/org/jenkinsci/plugins/foo/FooBarCause.java:8: error: class FooBarCause clashes with package of same name
      public class FooBarCause extends Cause {
             ^
      /home/.../foo-plugin/build/generated-src/localizer/org/jenkinsci/plugins/foo/FooBarCause/description.java:3: error: package org.jenkinsci.plugins.foo.FooBarCause clashes with class of 
      same name
      package org.jenkinsci.plugins.foo.FooBarCause;
      ^
      2 errors
      :compileJava FAILED
      
      
      

          [JENKINS-27451] All .properties files are being compiled by localizer, rather than just Messages.properties

          That's a common problem with Jenkins/Jelly, like in IDEA-80331 or GRECLIPSE-1076.

          Daniel Spilker added a comment - That's a common problem with Jenkins/Jelly, like in IDEA-80331 or GRECLIPSE-1076 .

          Sure, but I'm seeing this not in my IDE, but on the command line when running ./gradlew server.

          So I guess this is a problem with Gradle's Java support itself?

          Christopher Orr added a comment - Sure, but I'm seeing this not in my IDE, but on the command line when running ./gradlew server . So I guess this is a problem with Gradle's Java support itself?

          Ok, so the actual problem here is that description.properties is being compiled to Java at all; with the Maven HPI plugin this does not happen.
          No localizer output needs to be generated for this case; when the Jelly view is rendered, it seems to use the description.properties file directly.

          For Maven builds, the plugin parent POM explicitly sets the fileMask property to Messages.properties, so that only files matching that pattern will be considered by the localizer: https://github.com/jenkinsci/jenkins/blob/54af1e0/plugins/pom.xml#L114-L129

          It seems that the org.jvnet.localizer.GeneratorTask used by the Gradle JPI plugin's LocalizerTask doesn't have a fileMask property (though it does extend MatchingTask, so it should be possible to set the includes or excludes.
          So I think the simplest solution would be if the Gradle JPI plugin set the includes property by default to the value **/Messages.properties.

          Christopher Orr added a comment - Ok, so the actual problem here is that description.properties is being compiled to Java at all; with the Maven HPI plugin this does not happen. No localizer output needs to be generated for this case; when the Jelly view is rendered, it seems to use the description.properties file directly. For Maven builds, the plugin parent POM explicitly sets the fileMask property to Messages.properties , so that only files matching that pattern will be considered by the localizer: https://github.com/jenkinsci/jenkins/blob/54af1e0/plugins/pom.xml#L114-L129 It seems that the org.jvnet.localizer.GeneratorTask used by the Gradle JPI plugin's LocalizerTask doesn't have a fileMask property (though it does extend MatchingTask , so it should be possible to set the includes or excludes . So I think the simplest solution would be if the Gradle JPI plugin set the includes property by default to the value **/Messages.properties .

          Christopher Orr added a comment - - edited

          For now, my workaround is to add this to the end of my build.gradle:

          compileJava {
              exclude '**/description.java'
          }
          

          With that, the plugin can be compiled and functions as expected.

          Christopher Orr added a comment - - edited For now, my workaround is to add this to the end of my build.gradle : compileJava { exclude '**/description.java' } With that, the plugin can be compiled and functions as expected.

          Thanks for diving into this!

          I opened a pull request with a fix: https://github.com/jenkinsci/gradle-jpi-plugin/pull/48.

          Can you test the fix or do you have a public repo which I can use to test the fix?

          Daniel Spilker added a comment - Thanks for diving into this! I opened a pull request with a fix: https://github.com/jenkinsci/gradle-jpi-plugin/pull/48 . Can you test the fix or do you have a public repo which I can use to test the fix?

          Sorry, I don't have a public repo at the moment. But I built and tested the pull request, and it worked as expected. Thanks!

          Christopher Orr added a comment - Sorry, I don't have a public repo at the moment. But I built and tested the pull request, and it worked as expected. Thanks!

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          CHANGELOG.md
          src/main/groovy/org/jenkinsci/gradle/plugins/jpi/LocalizerTask.groovy
          http://jenkins-ci.org/commit/gradle-jpi-plugin/d06155b93251efc4bae3a20061d39021f7df5d3f
          Log:
          JENKINS-27451 localize only Message.properties files

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: CHANGELOG.md src/main/groovy/org/jenkinsci/gradle/plugins/jpi/LocalizerTask.groovy http://jenkins-ci.org/commit/gradle-jpi-plugin/d06155b93251efc4bae3a20061d39021f7df5d3f Log: JENKINS-27451 localize only Message.properties files

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          CHANGELOG.md
          src/main/groovy/org/jenkinsci/gradle/plugins/jpi/LocalizerTask.groovy
          http://jenkins-ci.org/commit/gradle-jpi-plugin/9f5e4dd856c979f389b5df3e53fcc0200eeb8a5e
          Log:
          Merge pull request #48 from daspilker/JENKINS-27451

          JENKINS-27451 localize only Message.properties files

          Compare: https://github.com/jenkinsci/gradle-jpi-plugin/compare/8b20ff9baf18...9f5e4dd856c9

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: CHANGELOG.md src/main/groovy/org/jenkinsci/gradle/plugins/jpi/LocalizerTask.groovy http://jenkins-ci.org/commit/gradle-jpi-plugin/9f5e4dd856c979f389b5df3e53fcc0200eeb8a5e Log: Merge pull request #48 from daspilker/ JENKINS-27451 JENKINS-27451 localize only Message.properties files Compare: https://github.com/jenkinsci/gradle-jpi-plugin/compare/8b20ff9baf18...9f5e4dd856c9

          Released in 0.10.1.

          Daniel Spilker added a comment - Released in 0.10.1.

            daspilker Daniel Spilker
            orrc Christopher Orr
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: