Uploaded image for project: 'PUBLIC - Liferay Maven'
  1. PUBLIC - Liferay Maven
  2. MAVEN-206

java.version is not passed to Maven causes "Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:24"

Details

    • Bug
    • Status: In Review
    • Major
    • Resolution: Unresolved
    • 6.2.0 GA1, 6.2.X
    • None
    • Liferay Artifacts
    • None

    Description

      The issue:
      The customer has a project that can be build with Liferay Portal Maven 6.2.1
      Now the user wants to use Liferay Portal Maven 6.2.15, however the plugin cannot be built.
      Exception snippet:

      [ERROR] Failed to execute goal com.liferay.maven.plugins:liferay-maven-plugin:6.2.10.15:build-css (default) on project nl-ou-dlwo-userprofile-portlet: Some problems were encountered while processing the POMs:
      [ERROR] [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:24, C:\Users\liferay\.m2\repository\org\apache\commons\commons-parent\24\commons-parent-24.pom, line 985, column 14: 1 problem was encountered while building the effective model for commons-io:commons-io:2.2
      [ERROR] [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:24, C:\Users\liferay\.m2\repository\org\apache\commons\commons-parent\24\commons-parent-24.pom, line 985, column 14
      

      Debug logged exception is attached (debuglog.txt)

      My assumption:
      As you can see the issue is coming from:
      https://github.com/liferay/liferay-maven-support/blob/6.2.10.15/plugins/liferay-maven-plugin/src/main/java/com/liferay/maven/plugins/AbstractToolsLiferayMojo.java

      AbstractToolsLiferayMojo.java
      		for (String activeProfile : mavenExecutionRequest.getActiveProfiles()) {
      			activeProfileIds.add(activeProfile);
      		}
      
      		projectBuildingRequest.setActiveProfileIds(activeProfileIds);
      		projectBuildingRequest.setProfiles(
      			mavenExecutionRequest.getProfiles());
      
      		ProjectBuildingResult projectBuildingResult = projectBuilder.build(
      			pomArtifact, true, projectBuildingRequest);
      
      		return projectBuildingResult.getProject();
      	}
      

      I believe the projectBuildingRequest should pass the JAVA_HOME value.
      Please note that this class does not exist in version 6.2.1.

      As it does not passes java.version, then it will be null and the build fails:
      https://github.com/apache/maven/blob/master/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java

      JdkVersionProfileActivator.java
              String version = context.getSystemProperties().get( "java.version" );
      
              if ( version == null || version.length() <= 0 )
              {
                  problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
                          .setMessage( "Failed to determine Java version for profile " + profile.getId() )
                          .setLocation( activation.getLocation( "jdk" ) ) );
                  return false;
              }
      

      Notes:
      Maven version: 3.1.1
      Built in: Liferay Developer Studio Version: 2.2.2.201504240205-ga3

      This is another product, however had the same issue:
      http://jdpgrailsdev.github.io/blog/2014/05/27/grails_maven_jdk_profile.html

      Thank you,
      Tibor

      Attachments

        Issue Links

          Activity

            People

              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                6 years, 5 days ago

                Packages

                  Version Package