Uploaded image for project: 'Maven Remote Resources Plugin'
  1. Maven Remote Resources Plugin
  2. MRRESOURCES-62

test-jar classifier fails in multi-module projects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.3
    • 1.5
    • None

    Description

      If a resourceBundle is a test-jar of a sibling project the process step will attempt to pull resources from /classes

          @SuppressWarnings( "unchecked" )
          private List<File> downloadBundles( List<String> bundles )
              throws MojoExecutionException
          {
              List<File> bundleArtifacts = new ArrayList<File>();
      
              try
              {
                  for ( String artifactDescriptor : bundles )
                  {
                      // groupId:artifactId:version[:type[:classifier]]
                      String[] s = artifactDescriptor.split( ":" );
      
                      File artifactFile = null;
                      //check if the artifact is part of the reactor
                      if ( mavenSession != null )
                      {
                          List<MavenProject> list = mavenSession.getSortedProjects();
                          for ( MavenProject p : list )
                          {
                              if ( s[0].equals( p.getGroupId() ) && s[1].equals( p.getArtifactId() ) && s[2].equals(
                                  p.getVersion() ) )
                              {
                                  // FIXME Needs to depend on classifier
                                  // Should be like:
                                  // if("test-jar".equals(type))
                                  //{
                                  //   artifactFile = new File( p.getBuild().testOutputDirectory());
                                  // }
                                  // else
                                  // {
                                         artifactFile = new File( p.getBuild().getOutputDirectory() );
                                  // }
                              }
                          }
                      }
                      if ( artifactFile == null || !artifactFile.exists() )
                      {
                          String type = ( s.length >= 4 ? s[3] : "jar" );
                          String classifier = ( s.length == 5 ? s[4] : null );
                          Artifact artifact =
                              artifactFactory.createDependencyArtifact( s[0], s[1], VersionRange.createFromVersion( s[2] ),
                                                                        type, classifier, Artifact.SCOPE_RUNTIME );
      
                          artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
      
                          artifactFile = artifact.getFile();
                      }
                      bundleArtifacts.add( artifactFile );
                  }
              }
              catch ( ArtifactResolutionException e )
              {
                  throw new MojoExecutionException( "Error downloading resources archive.", e );
              }
              catch ( ArtifactNotFoundException e )
              {
                  throw new MojoExecutionException( "Resources archive cannot be found.", e );
              }
      
              return bundleArtifacts;
          }
      

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            jeff.maxwell Jeff Maxwell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: