[jira] Created: (FELIX-1819) Problem trying

View: New views
7 Messages — Rating Filter:   Alert me  

[jira] Created: (FELIX-1819) Problem trying

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Problem trying
---------------

                 Key: FELIX-1819
                 URL: https://issues.apache.org/jira/browse/FELIX-1819
             Project: Felix
          Issue Type: Bug
          Components: Maven SCR Plugin
    Affects Versions: maven-scr-plugin-1.2.0
            Reporter: Rembert Magri
             Fix For: maven-scr-plugin-1.4.1
         Attachments: JavaClassDescriptorManager.java

When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:

protected Manifest getManifest(Artifact artifact) throws IOException {
    if (!this.isJavaArtifact(artifact)) {
    throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
    }
   
    if ("bundle".equals(artifact.getType())) {
    return getManifestFromBundle(artifact);
    }
   
    return getManifestFromJarFile(artifact);
       
    }

        private Manifest getManifestFromBundle(Artifact artifact)
                        throws FileNotFoundException, IOException {
                //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
                File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
                FileInputStream manifestInputStream = null;
                try {
                        manifestInputStream = new FileInputStream(file);
                        return new Manifest(manifestInputStream);
                } finally {
                        if (manifestInputStream != null) {
                                try {
                                        manifestInputStream.close();
                        } catch (IOException ignore) {
                        }
                        }
                }
        }

        private Manifest getManifestFromJarFile(Artifact artifact)
                        throws IOException {
                JarFile file = null;
                try {
                    file = new JarFile(artifact.getFile());
                    return file.getManifest();
                } finally {
                    if (file != null) {
                        try {
                            file.close();
                        } catch (IOException ignore) {
                        }
                    }
                }
        }

    protected File getFile(Artifact artifact, String path) throws IOException {
    if ("bundle".equals(artifact.getType())) {
    return getFileFromBundle(artifact, path);
    }
   
        return getFileFromJar(artifact, path);
    }

        private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
                //artifact.getFile() returns {project}/target/classes, and I want {project}/path
                File file = artifact.getFile();
                File targetFile = new File(file.getParentFile().getParentFile(),path);
                if (targetFile.canRead()) {
                        return targetFile;
                }
                log.warn("Won't be able to read: " + targetFile);
                return null;
        }

        private File getFileFromJar(Artifact artifact, String path)
                        throws IOException, FileNotFoundException {
                final int pos = path.lastIndexOf('.');
        final String suffix = path.substring(pos + 1);
        JarFile file = null;
        File tmpFile = null;
        try {
            file = new JarFile(artifact.getFile());
            final JarEntry entry = file.getJarEntry(path);
            if ( entry != null ) {
                tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
                tmpFile.deleteOnExit();
                final FileOutputStream fos = new FileOutputStream(tmpFile);
                IOUtil.copy(file.getInputStream(entry), fos);
                IOUtil.close(fos);
                return tmpFile;
            }
            return null;
        } finally {
            if (file != null) {
                try {
                    file.close();
                } catch (IOException ignore) {
                }
            }
        }
        }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-1819) Problem trying

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rembert Magri updated FELIX-1819:
---------------------------------

    Attachment: JavaClassDescriptorManager.java

> Problem trying
> ---------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-1819) Problem with dependencies resolution

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rembert Magri updated FELIX-1819:
---------------------------------

    Summary: Problem with dependencies resolution  (was: Problem trying )

> Problem with dependencies resolution
> ------------------------------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1819) Problem with dependencies resolution

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12773143#action_12773143 ]

Carsten Ziegeler commented on FELIX-1819:
-----------------------------------------

Could you please create a proper patch for the current trunk?

> Problem with dependencies resolution
> ------------------------------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>            Assignee: Carsten Ziegeler
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-1819) Problem with dependencies resolution

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler reassigned FELIX-1819:
---------------------------------------

    Assignee: Carsten Ziegeler

> Problem with dependencies resolution
> ------------------------------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>            Assignee: Carsten Ziegeler
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-1819) Problem with dependencies resolution

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12775376#action_12775376 ]

Rembert Magri commented on FELIX-1819:
--------------------------------------

Carsten,

I have just tested the issue using the latest version (trunk, 1.4.1), and the changes made by Felix Meschbe (revision 820997) solved the problem. This issue can be closed.

> Problem with dependencies resolution
> ------------------------------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>            Assignee: Carsten Ziegeler
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (FELIX-1819) Problem with dependencies resolution

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/FELIX-1819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler resolved FELIX-1819.
-------------------------------------

    Resolution: Cannot Reproduce

Many thanks for the update!
I'll resolve this bug to cannot reproduce.

> Problem with dependencies resolution
> ------------------------------------
>
>                 Key: FELIX-1819
>                 URL: https://issues.apache.org/jira/browse/FELIX-1819
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions: maven-scr-plugin-1.2.0
>            Reporter: Rembert Magri
>            Assignee: Carsten Ziegeler
>             Fix For: maven-scr-plugin-1.4.1
>
>         Attachments: JavaClassDescriptorManager.java
>
>
> When adding dependencies with "provided" scope, the plugin cannot find the bundle correctly. I fixed the problem by changing the getManifest and getFile methods as follows:
> protected Manifest getManifest(Artifact artifact) throws IOException {
>     if (!this.isJavaArtifact(artifact)) {
>     throw new IllegalArgumentException("Trying to load Manifest from a non-Java type");
>     }
>    
>     if ("bundle".equals(artifact.getType())) {
>     return getManifestFromBundle(artifact);
>     }
>    
>     return getManifestFromJarFile(artifact);
>        
>     }
> private Manifest getManifestFromBundle(Artifact artifact)
> throws FileNotFoundException, IOException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/META-INF/MANIFEST.MF
> File file = getFileFromBundle(artifact, "META-INF/MANIFEST.MF");
> FileInputStream manifestInputStream = null;
> try {
> manifestInputStream = new FileInputStream(file);
> return new Manifest(manifestInputStream);
> } finally {
> if (manifestInputStream != null) {
> try {
> manifestInputStream.close();
>        } catch (IOException ignore) {
>        }
> }
> }
> }
> private Manifest getManifestFromJarFile(Artifact artifact)
> throws IOException {
> JarFile file = null;
> try {
>    file = new JarFile(artifact.getFile());
>    return file.getManifest();
> } finally {
>    if (file != null) {
>        try {
>            file.close();
>        } catch (IOException ignore) {
>        }
>    }
> }
> }
>     protected File getFile(Artifact artifact, String path) throws IOException {
>     if ("bundle".equals(artifact.getType())) {
>     return getFileFromBundle(artifact, path);
>     }
>    
>         return getFileFromJar(artifact, path);
>     }
> private File getFileFromBundle(Artifact artifact, String path) throws FileNotFoundException {
> //artifact.getFile() returns {project}/target/classes, and I want {project}/path
> File file = artifact.getFile();
> File targetFile = new File(file.getParentFile().getParentFile(),path);
> if (targetFile.canRead()) {
> return targetFile;
> }
> log.warn("Won't be able to read: " + targetFile);
> return null;
> }
> private File getFileFromJar(Artifact artifact, String path)
> throws IOException, FileNotFoundException {
> final int pos = path.lastIndexOf('.');
>         final String suffix = path.substring(pos + 1);
>         JarFile file = null;
>         File tmpFile = null;
>         try {
>             file = new JarFile(artifact.getFile());
>             final JarEntry entry = file.getJarEntry(path);
>             if ( entry != null ) {
>                 tmpFile = File.createTempFile("scrjcdm" + artifact.getArtifactId(), suffix);
>                 tmpFile.deleteOnExit();
>                 final FileOutputStream fos = new FileOutputStream(tmpFile);
>                 IOUtil.copy(file.getInputStream(entry), fos);
>                 IOUtil.close(fos);
>                 return tmpFile;
>             }
>             return null;
>         } finally {
>             if (file != null) {
>                 try {
>                     file.close();
>                 } catch (IOException ignore) {
>                 }
>             }
>         }
> }

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.