jira-importer commented on issue #392:
URL: 
https://github.com/apache/maven-ear-plugin/issues/392#issuecomment-2955288010

   **[Marat 
Abrarov](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=abrarovm)**
 commented
   
   [Maxim 
Frolov](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=wrungel), 
what about custom artifact type mappings - 
[artifactTypeMappings](https://maven.apache.org/plugins/maven-ear-plugin/generate-application-xml-mojo.html#artifactTypeMappings)
 configuration parameter of ear:generate-application-xml and ear:ear goals?
   
   I tried this configuration (upgraded till the latest GA version of Maven EAR 
Plugin and added artifactTypeMappings option):
   
   ```xml
   <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-ear-plugin</artifactId>
       <version>3.0.2</version>
       <configuration>
           <version>7</version>
           <defaultLibBundleDir>lib</defaultLibBundleDir>
           <useBaseVersion>true</useBaseVersion>
           <artifactTypeMappings>
               <artifactTypeMapping type="test-jar" mapping="jar"/>
           </artifactTypeMappings>
       </configuration>
   </plugin>
   ```
   
   for [^test-jar-in-ear-2.zip] maven project you provided and it works:
   
   ```
   $ mvn clean package
   ...
   [INFO] ----------------------< frol:test-jar-in-ear-ear 
>----------------------
   [INFO] Building test-jar-in-ear-ear 1.0-SNAPSHOT                          
[3/3]
   [INFO] --------------------------------[ ear 
]---------------------------------
   [INFO] 
   [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ 
test-jar-in-ear-ear ---
   [INFO] 
   [INFO] --- maven-ear-plugin:3.0.2:generate-application-xml 
(default-generate-application-xml) @ test-jar-in-ear-ear ---
   [WARNING] Using useBaseVersion not yet fixed.
   [INFO] Generating application.xml
   [INFO] 
   [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ 
test-jar-in-ear-ear ---
   [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
resources, i.e. build is platform dependent!
   [INFO] skip non existing resourceDirectory 
D:\Users\Marat\Documents\work\java\test-jar-in-ear\ear\src\main\resources
   [INFO] 
   [INFO] --- maven-ear-plugin:3.0.2:ear (default-ear) @ test-jar-in-ear-ear ---
   [WARNING] Using useBaseVersion not yet fixed.
   [INFO] Copying artifact [jar:frol:test-jar-in-ear-lib:1.0-SNAPSHOT] to 
[lib/frol-test-jar-in-ear-lib-1.0-SNAPSHOT.jar]
   [INFO] Copying artifact [jar:frol:test-jar-in-ear-lib:tests:1.0-SNAPSHOT] to 
[lib/frol-test-jar-in-ear-lib-1.0-SNAPSHOT-tests.jar]
   [INFO] Copy ear sources to 
D:\Users\Marat\Documents\work\java\test-jar-in-ear\ear\target\test-jar-in-ear-ear-1.0-SNAPSHOT
   [INFO] Building jar: 
D:\Users\Marat\Documents\work\java\test-jar-in-ear\ear\target\test-jar-in-ear-ear-1.0-SNAPSHOT.ear
   [INFO] 
------------------------------------------------------------------------
   [INFO] Reactor Summary for test-jar-in-ear-parent 1.0-SNAPSHOT:
   [INFO] 
   [INFO] test-jar-in-ear-parent ............................. SUCCESS [  0.194 
s]
   [INFO] test-jar-in-ear-lib ................................ SUCCESS [  2.390 
s]
   [INFO] test-jar-in-ear-ear ................................ SUCCESS [  0.892 
s]
   [INFO] 
------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] 
------------------------------------------------------------------------
   [INFO] Total time:  3.655 s (Wall Clock)
   [INFO] Finished at: 2020-09-15T08:56:36+03:00
   [INFO] 
------------------------------------------------------------------------
   
   $ cat ear/target/application.xml
   <?xml version="1.0" encoding="UTF-8"?>
   <application xmlns="http://xmlns.jcp.org/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"; version="7">
     <display-name>test-jar-in-ear-ear</display-name>
     <library-directory>lib</library-directory>
   </application>
   
   $ unzip -l ear/target/test-jar-in-ear-ear-1.0-SNAPSHOT.ear
   Archive:  ear/target/test-jar-in-ear-ear-1.0-SNAPSHOT.ear
     Length      Date    Time    Name
   ---------  ---------- -----   ----
          95  09-15-2020 09:04   META-INF/MANIFEST.MF
           0  09-15-2020 09:04   META-INF/
           0  09-15-2020 09:04   lib/
           0  09-15-2020 09:04   META-INF/maven/
           0  09-15-2020 09:04   META-INF/maven/frol/
           0  09-15-2020 09:04   META-INF/maven/frol/test-jar-in-ear-ear/
        2076  09-15-2020 09:04   
lib/frol-test-jar-in-ear-lib-1.0-SNAPSHOT-tests.jar
         381  09-15-2020 09:04   META-INF/application.xml
        1684  09-15-2020 08:56   META-INF/maven/frol/test-jar-in-ear-ear/pom.xml
          96  09-15-2020 09:04   
META-INF/maven/frol/test-jar-in-ear-ear/pom.properties
        2082  09-15-2020 09:04   lib/frol-test-jar-in-ear-lib-1.0-SNAPSHOT.jar
   ---------                     -------
        6414                     11 files
   ```
   
   Refer to 
[`org.apache.maven.plugins.ear.util.ArtifactTypeMappingService`](https://github.com/apache/maven-ear-plugin/blob/maven-ear-plugin-3.0.2/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java)
 class and to 
[`org.apache.maven.plugins.ear.util.ArtifactRepository#getArtifacts`](https://github.com/apache/maven-ear-plugin/blob/maven-ear-plugin-3.0.2/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java#L138)
 method which is called by 
[`org.apache.maven.plugins.ear.JarModule#resolveArtifact`](https://github.com/apache/maven-ear-plugin/blob/maven-ear-plugin-3.0.2/src/main/java/org/apache/maven/plugins/ear/JarModule.java#L91)
 method when generating application.xml and packaging EAR file.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to