Jetty
  1. Jetty
  2. JETTY-330

Jetty JscpC Mojo and dependencies with scope provided

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Maven
    • Labels:
      None
    • Number of attachments :
      0

      Description

      in setUpClassPath(WebAppClassLoader classLoader) the dependent artifacts should be discovered using project.getDependencyArtifacts() instead of project.getArtifacts(). This would allow JSPs to compile correctly if they depend on artifacts with scope provided.

      "Patch":

      http://fe.reucon.net/fisheye/browse/repos/maven/plugins/maven-openfire-plugin/trunk/src/main/java/com/reucon/maven/plugin/openfire/AbstractOpenfireMojo.java?r1=661&r2=664

        Activity

        Show
        Stefan Reuter added a comment - Sorry, wrong link. The correct one is: http://fe.reucon.net/fisheye/browse/repos/maven/plugins/maven-openfire-plugin/trunk/src/main/java/com/reucon/maven/plugin/openfire/jspc/JspcMojo.java?r1=659&r2=664
        Jan Bartel made changes -
        Field Original Value New Value
        Assignee Jan Bartel [ janb ]
        Hide
        Jan Bartel added a comment -

        Hi Stefan,

        I'm not sure about this change. The maven javadoc says:

        getArtifacts()
        All dependencies that this project has, including transitive ones.

        getDependencyArtifacts()
        Direct dependencies that this project has.

        We need all the artifacts, including the transitive ones, don't we?

        Show
        Jan Bartel added a comment - Hi Stefan, I'm not sure about this change. The maven javadoc says: getArtifacts() All dependencies that this project has, including transitive ones. getDependencyArtifacts() Direct dependencies that this project has. We need all the artifacts, including the transitive ones, don't we?
        Hide
        Stefan Reuter added a comment -

        Hm thats right. In fact I used it with a project where only direct depencies where used for compiling.
        It seems we need the set union of both, right?

        Show
        Stefan Reuter added a comment - Hm thats right. In fact I used it with a project where only direct depencies where used for compiling. It seems we need the set union of both, right?
        Hide
        Stefan Reuter added a comment -

        How about this:

            private void setUpClassPath(WebAppClassLoader classLoader) throws Exception
            {       
                String classesDir = classesDirectory.getCanonicalPath();
                classesDir = classesDir + (classesDir.endsWith(File.pathSeparator)?"":File.separator);
                classLoader.addClassPath(classesDir);
                if (getLog().isDebugEnabled()) getLog().debug("Adding to classpath classes dir: "+classesDir);
        
                Collection artifactsAdded = new HashSet();
                for ( Iterator iter = project.getArtifacts().iterator(); iter.hasNext(); )
                {
                    Artifact artifact = (Artifact) iter.next();
                    String filePath = artifact.getFile().getCanonicalPath();
        
                    if (!Artifact.SCOPE_TEST.equals( artifact.getScope()) )
                    {
                        if (getLog().isDebugEnabled())
                            getLog().debug("Adding to classpath dependency file: "+filePath);
                            
                        classLoader.addClassPath(filePath);
                        artifactsAdded.add(filePath);
                    }
                }
                for ( Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext(); )
                {
                    Artifact artifact = (Artifact) iter.next();
                    String filePath = artifact.getFile().getCanonicalPath();
        
                    if (!Artifact.SCOPE_TEST.equals( artifact.getScope()) && ! artifactsAdded.contains(filePath))
                    {
                        if (getLog().isDebugEnabled())
                            getLog().debug("Adding to classpath dependency file: "+filePath);
        
                        classLoader.addClassPath(filePath);
                    }
                }
        
        Show
        Stefan Reuter added a comment - How about this: private void setUpClassPath(WebAppClassLoader classLoader) throws Exception { String classesDir = classesDirectory.getCanonicalPath(); classesDir = classesDir + (classesDir.endsWith(File.pathSeparator)?"":File.separator); classLoader.addClassPath(classesDir); if (getLog().isDebugEnabled()) getLog().debug( "Adding to classpath classes dir: " +classesDir); Collection artifactsAdded = new HashSet(); for ( Iterator iter = project.getArtifacts().iterator(); iter.hasNext(); ) { Artifact artifact = (Artifact) iter.next(); String filePath = artifact.getFile().getCanonicalPath(); if (!Artifact.SCOPE_TEST.equals( artifact.getScope()) ) { if (getLog().isDebugEnabled()) getLog().debug( "Adding to classpath dependency file: " +filePath); classLoader.addClassPath(filePath); artifactsAdded.add(filePath); } } for ( Iterator iter = project.getDependencyArtifacts().iterator(); iter.hasNext(); ) { Artifact artifact = (Artifact) iter.next(); String filePath = artifact.getFile().getCanonicalPath(); if (!Artifact.SCOPE_TEST.equals( artifact.getScope()) && ! artifactsAdded.contains(filePath)) { if (getLog().isDebugEnabled()) getLog().debug( "Adding to classpath dependency file: " +filePath); classLoader.addClassPath(filePath); } }
        Hide
        Jan Bartel added a comment -

        Hi Stefan,

        I believe if you change the @requiresDependencyResolution to value "compile" instead of runtime, you'll get the scope=provided dependencies. Can you try this out and let me know if it works? I think I'd also have to add some checks to ensure that the jetty jars can't be included (as duplicates) via this mechanism (ie due to a dependency of scope=provided).

        cheers
        Jan

        Show
        Jan Bartel added a comment - Hi Stefan, I believe if you change the @requiresDependencyResolution to value "compile" instead of runtime, you'll get the scope=provided dependencies. Can you try this out and let me know if it works? I think I'd also have to add some checks to ensure that the jetty jars can't be included (as duplicates) via this mechanism (ie due to a dependency of scope=provided). cheers Jan
        Hide
        Stefan Reuter added a comment -

        Hi Jan,

        changing @requiresDependencyResolution to "compile" fixes the problem.
        This seems to be the correct solution.

        Thanks,
        Stefan

        Show
        Stefan Reuter added a comment - Hi Jan, changing @requiresDependencyResolution to "compile" fixes the problem. This seems to be the correct solution. Thanks, Stefan
        Hide
        Jan Bartel added a comment -

        I've changed the requiresDependencyResolution as mentioned above. At the same time, I removed the dependency on the main jetty jar, leaving just the dependency on the jetty-util jar. See svn rev 1876.

        Show
        Jan Bartel added a comment - I've changed the requiresDependencyResolution as mentioned above. At the same time, I removed the dependency on the main jetty jar, leaving just the dependency on the jetty-util jar. See svn rev 1876.
        Jan Bartel made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Jan Bartel
            Reporter:
            Stefan Reuter
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: