Hello,

(I apologize in advance if this issue was addressed already. Jira ticket at: http://jira.codehaus.org/browse/MNG-3262 which contains the source and pom of the plugin and project that uses the plugin)

Wondering if anyone can spot anything stupid I'm doing here...

I've written a Maven 2 mojo that is having trouble instantiating (via reflection) a properties resource of dependency that is included as a "compile"-scope dependency in the project (pom.xml) that is utilizing my plugin.

(Even though I need the plugin to access a dependency that is in "provided" scope, for now I'm using compile scope since the maven documentation states that @requiresDependencyResolution doesn't support provided scope.)

Here are the details:

1) I have the following dependency:

---start---
   <dependencies>
       <dependency>
           <groupId>com.atlassian.confluence</groupId>
           <artifactId>confluence</artifactId>
           <version>2.6.0</version>
           <scope>compile</scope>
       </dependency>
   </dependencies>
---end---

2) In the pom.xml of the project that utilizes my plugin, the mojo of the plugin I wrote is configured with the execution:

---start---
                   <execution>
                       <id>get_ConfluenceActionSupport.properties</id>
                       <phase>compile</phase>
                       <goals>
                           <goal>extractProperties</goal>
                       </goals>
                       <configuration>
<fullyQualifiedProperties>com.atlassian.confluence.core.ConfluenceActionSupport.properties</fullyQualifiedProperties> <outputFile>target/classes/com/atlassian/confluence/core/ConfluenceActionSupport.properties</outputFile>
                       </configuration>
                   </execution>
---end---

3) In the Maven 2 mojo it calls the following code (just copied/pasted the relevant portion):

---start---
       // load properties with reflection and save to file
       InputStream in = null;
       OutputStream out = null;

       boolean foundFile = false;
       try {
           String resource = cleanResourceName(fullyQualifiedProperties);
           System.out.println("Getting " + resource);
           in = getClass().getResourceAsStream (resource);
           if (in != null)
           {
               Properties result = new Properties();
               result.load (in); // Can throw IOException
out = new BufferedOutputStream(new FileOutputStream(outputPathname));
               result.store(out, "");
               foundFile = true;
           }
       }
---end---

When executed, it can't find the properties file in the classloader. As you can see from the following output, I'm putting the resource string together correctly as "/com/atlassian/confluence/core/ConfluenceActionSupport.properties" which if you interrogate the above confluence dependency, you should be able to find.

---start---
[INFO] [i18nsanity-pt:extractProperties {execution: get_ConfluenceActionSupport.properties}] [INFO] Extracting properties file from classpath... fullyQualifiedProperties=com.atlassian.confluence.core.ConfluenceActionSupport.properties outputFile=/usr/svn/community/confluence/plugins/americanenglishlanguagepack/trunk/target/classes/com/atlassian/confluence/core/ConfluenceActionSupport.properties
Getting /com/atlassian/confluence/core/ConfluenceActionSupport.properties
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed properties extraction!

Embedded error: Could not find properties file on classpath: com.atlassian.confluence.core.ConfluenceActionSupport.properties
---end---


Thanks!

--
Gary Weaver
Internet Framework Services
Office of Information Technology
Duke University


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to