<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="https://nozaki.me/roller/roller-ui/styles/rss.xsl" media="screen"?><rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:atom="http://www.w3.org/2005/Atom" >
<channel>
  <title>Kohei Nozaki&apos;s blog</title>
  <link>https://nozaki.me/roller/kyle/</link>
      <atom:link rel="self" type="application/rss+xml" href="https://nozaki.me/roller/kyle/feed/entries/rss?cat=Maven" />
    <description>Notes of my experiments</description>
  <language>en-us</language>
  <copyright>Copyright 2024</copyright>
  <lastBuildDate>Wed, 1 May 2024 08:28:13 +0000</lastBuildDate>
  <generator>Apache Roller 5.2.0</generator>
        <item>
    <guid isPermaLink="true">https://nozaki.me/roller/kyle/entry/building-environment-specific-artifacts-with</guid>
    <title>Building environment specific artifacts with classifier</title>
    <dc:creator>Kohei Nozaki</dc:creator>
    <link>https://nozaki.me/roller/kyle/entry/building-environment-specific-artifacts-with</link>
        <pubDate>Fri, 20 Mar 2015 06:09:27 +0000</pubDate>
    <category>Maven</category>
    <category>jpa</category>
    <category>maven</category>
            <description>&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Consider following multi-module Maven project:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;ulist&quot;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;classifier&lt;/code&gt;: The parent &amp;amp; aggregator project&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;persistence&lt;/code&gt;: A jar project which holds JPA entities and a persistence descriptor (&lt;code&gt;persistence.xml&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;web&lt;/code&gt;: A war project which depends on &lt;code&gt;persistence&lt;/code&gt; project&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;&lt;code&gt;persistence&lt;/code&gt; project contains following persistence descriptor:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;persistence version=&quot;2.1&quot; xmlns=&quot;http://xmlns.jcp.org/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd&quot;&amp;gt;
    &amp;lt;persistence-unit name=&quot;myPU&quot;&amp;gt;
        &amp;lt;jta-data-source&amp;gt;java:jboss/datasources/ExampleDS&amp;lt;/jta-data-source&amp;gt;
        &amp;lt;properties&amp;gt;
            &amp;lt;property name=&quot;javax.persistence.schema-generation.database.action&quot;
                      value=&quot;${javax.persistence.schema-generation.database.action}&quot;/&amp;gt;
        &amp;lt;/properties&amp;gt;
    &amp;lt;/persistence-unit&amp;gt;
&amp;lt;/persistence&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;I need to set &lt;code&gt;javax.persistence.schema-generation.database.action&lt;/code&gt; property as &lt;code&gt;drop-and-create&lt;/code&gt; for development environment, but &lt;code&gt;none&lt;/code&gt; for production environment. in such case, using profiles and filtering might be a solution, but its shortcoming is that we can hold only one (among environment specific builds) artifact in the local repository because these builds has same coordinate. it may bring unexpected result such as deploying development build to the production environment by some accident. in such case, using classifier would be a better solution.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/lbtc-xxx/classifier&quot;&gt;The example project can be obtained from my GitHub repository&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_preparation&quot;&gt;Preparation&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;First, let&amp;#8217;s enable resource filtering in &lt;code&gt;persistence&lt;/code&gt; project.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;build&amp;gt;
    &amp;lt;resources&amp;gt;
        &amp;lt;resource&amp;gt;
            &amp;lt;directory&amp;gt;src/main/resources&amp;lt;/directory&amp;gt;
            &amp;lt;filtering&amp;gt;true&amp;lt;/filtering&amp;gt;
        &amp;lt;/resource&amp;gt;
    &amp;lt;/resources&amp;gt;

    &amp;lt;plugins&amp;gt;
        &amp;lt;plugin&amp;gt;
            &amp;lt;artifactId&amp;gt;maven-resources-plugin&amp;lt;/artifactId&amp;gt;
            &amp;lt;executions&amp;gt;
                &amp;lt;!-- Filter and copy resources under src/main/resources into target/classes (default location) --&amp;gt;
                &amp;lt;execution&amp;gt;
                    &amp;lt;id&amp;gt;default-resources&amp;lt;/id&amp;gt;
                    &amp;lt;phase&amp;gt;process-resources&amp;lt;/phase&amp;gt;
                    &amp;lt;goals&amp;gt;
                        &amp;lt;goal&amp;gt;resources&amp;lt;/goal&amp;gt;
                    &amp;lt;/goals&amp;gt;
                    &amp;lt;configuration&amp;gt;
                        &amp;lt;filters&amp;gt;
                            &amp;lt;filter&amp;gt;${basedir}/filters/dev.properties&amp;lt;/filter&amp;gt;
                        &amp;lt;/filters&amp;gt;
                    &amp;lt;/configuration&amp;gt;
                &amp;lt;/execution&amp;gt;
            &amp;lt;/executions&amp;gt;
        &amp;lt;/plugin&amp;gt;
    &amp;lt;/plugins&amp;gt;
&amp;lt;/build&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Then put &lt;code&gt;filters/dev.properties&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;javax.persistence.schema-generation.database.action=drop-and-create&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Set a dependency in &lt;code&gt;web&lt;/code&gt; project:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;dependencies&amp;gt;
    &amp;lt;dependency&amp;gt;
        &amp;lt;groupId&amp;gt;org.nailedtothex.examples.classifier&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;persistence&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
&amp;lt;/dependencies&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_add_configurations_for_producing_artifacts_for_production&quot;&gt;Add configurations for producing artifacts for production&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Now we can make artifacts that holds filtered &lt;code&gt;persistence.xml&lt;/code&gt; for development environment. next, let&amp;#8217;s add configurations for producing artifacts for production environment with &lt;code&gt;prod&lt;/code&gt; classifier.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Put following profile definition into &lt;code&gt;persistence&lt;/code&gt; project to make the project to produce both of development and production (with &lt;code&gt;prod&lt;/code&gt; classifier) artifacts:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;profile&amp;gt;
    &amp;lt;id&amp;gt;prod&amp;lt;/id&amp;gt;
    &amp;lt;properties&amp;gt;
        &amp;lt;filteredResources&amp;gt;target/filtered-classes&amp;lt;/filteredResources&amp;gt;
    &amp;lt;/properties&amp;gt;
    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-resources-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;!-- Filter and copy resources under src/main/resources into target/filtered-classes/prod --&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;id&amp;gt;prod-resources&amp;lt;/id&amp;gt;
                        &amp;lt;phase&amp;gt;process-resources&amp;lt;/phase&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;resources&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                        &amp;lt;configuration&amp;gt;
                            &amp;lt;outputDirectory&amp;gt;${filteredResources}/prod&amp;lt;/outputDirectory&amp;gt;
                            &amp;lt;filters&amp;gt;
                                &amp;lt;filter&amp;gt;${basedir}/filters/prod.properties&amp;lt;/filter&amp;gt;
                            &amp;lt;/filters&amp;gt;
                        &amp;lt;/configuration&amp;gt;
                    &amp;lt;/execution&amp;gt;
                    &amp;lt;!-- Copy classes under target/classes into target/filtered-classes/prod --&amp;gt;
                    &amp;lt;!-- Existing files will not be overwritten. --&amp;gt;
                    &amp;lt;!-- see http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#overwrite --&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;id&amp;gt;copy-classes-prod&amp;lt;/id&amp;gt;
                        &amp;lt;phase&amp;gt;process-classes&amp;lt;/phase&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;copy-resources&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                        &amp;lt;configuration&amp;gt;
                            &amp;lt;outputDirectory&amp;gt;${filteredResources}/prod&amp;lt;/outputDirectory&amp;gt;
                            &amp;lt;resources&amp;gt;
                                &amp;lt;resource&amp;gt;
                                    &amp;lt;directory&amp;gt;${project.build.outputDirectory}&amp;lt;/directory&amp;gt;
                                    &amp;lt;filtering&amp;gt;false&amp;lt;/filtering&amp;gt;
                                &amp;lt;/resource&amp;gt;
                            &amp;lt;/resources&amp;gt;
                        &amp;lt;/configuration&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
            &amp;lt;/plugin&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-jar-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;!-- Create the production jar with files inside target/filtered-classes/prod  --&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;id&amp;gt;prod-jar&amp;lt;/id&amp;gt;
                        &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;jar&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                        &amp;lt;configuration&amp;gt;
                            &amp;lt;classifier&amp;gt;prod&amp;lt;/classifier&amp;gt;
                            &amp;lt;classesDirectory&amp;gt;${filteredResources}/prod&amp;lt;/classesDirectory&amp;gt;
                        &amp;lt;/configuration&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&amp;lt;/profile&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Also put &lt;code&gt;filters/prod.properties&lt;/code&gt;:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;javax.persistence.schema-generation.database.action=none&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Issue following command:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ mvn clean install -P prod&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Result:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;...
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ persistence ---
[INFO] Building jar: /Users/kyle/src/classifier/persistence/target/persistence-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (prod-jar) @ persistence ---
[INFO] Building jar: /Users/kyle/src/classifier/persistence/target/persistence-1.0-SNAPSHOT-prod.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ persistence ---
[INFO] Installing /Users/kyle/src/classifier/persistence/target/persistence-1.0-SNAPSHOT.jar to /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/persistence/1.0-SNAPSHOT/persistence-1.0-SNAPSHOT.jar
[INFO] Installing /Users/kyle/src/classifier/persistence/pom.xml to /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/persistence/1.0-SNAPSHOT/persistence-1.0-SNAPSHOT.pom
[INFO] Installing /Users/kyle/src/classifier/persistence/target/persistence-1.0-SNAPSHOT-prod.jar to /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/persistence/1.0-SNAPSHOT/persistence-1.0-SNAPSHOT-prod.jar
...&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;You can see both of artifacts are installed as expected:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ unzip -p /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/persistence/1.0-SNAPSHOT/persistence-1.0-SNAPSHOT.jar META-INF/persistence.xml
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;persistence version=&quot;2.1&quot; xmlns=&quot;http://xmlns.jcp.org/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd&quot;&amp;gt;
    &amp;lt;persistence-unit name=&quot;myPU&quot;&amp;gt;
        &amp;lt;jta-data-source&amp;gt;java:jboss/datasources/ExampleDS&amp;lt;/jta-data-source&amp;gt;
        &amp;lt;properties&amp;gt;
            &amp;lt;property name=&quot;javax.persistence.schema-generation.database.action&quot;
                      value=&quot;drop-and-create&quot;/&amp;gt;
        &amp;lt;/properties&amp;gt;
    &amp;lt;/persistence-unit&amp;gt;
&amp;lt;/persistence&amp;gt;

$ unzip -p /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/persistence/1.0-SNAPSHOT/persistence-1.0-SNAPSHOT-prod.jar META-INF/persistence.xml
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;persistence version=&quot;2.1&quot; xmlns=&quot;http://xmlns.jcp.org/xml/ns/persistence&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd&quot;&amp;gt;
    &amp;lt;persistence-unit name=&quot;myPU&quot;&amp;gt;
        &amp;lt;jta-data-source&amp;gt;java:jboss/datasources/ExampleDS&amp;lt;/jta-data-source&amp;gt;
        &amp;lt;properties&amp;gt;
            &amp;lt;property name=&quot;javax.persistence.schema-generation.database.action&quot;
                      value=&quot;none&quot;/&amp;gt;
        &amp;lt;/properties&amp;gt;
    &amp;lt;/persistence-unit&amp;gt;
&amp;lt;/persistence&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;So what is needed for &lt;code&gt;web&lt;/code&gt; project? put following profile as well:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;profile&amp;gt;
    &amp;lt;id&amp;gt;prod&amp;lt;/id&amp;gt;
    &amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.nailedtothex.examples.classifier&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;persistence&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
            &amp;lt;classifier&amp;gt;prod&amp;lt;/classifier&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;
    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-war-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;id&amp;gt;default-war&amp;lt;/id&amp;gt;
                        &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;war&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                        &amp;lt;configuration&amp;gt;
                            &amp;lt;packagingExcludes&amp;gt;WEB-INF/lib/persistence-1.0-SNAPSHOT-prod.jar&amp;lt;/packagingExcludes&amp;gt;
                        &amp;lt;/configuration&amp;gt;
                    &amp;lt;/execution&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;id&amp;gt;prod-war&amp;lt;/id&amp;gt;
                        &amp;lt;phase&amp;gt;package&amp;lt;/phase&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;war&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                        &amp;lt;configuration&amp;gt;
                            &amp;lt;classifier&amp;gt;prod&amp;lt;/classifier&amp;gt;
                            &amp;lt;packagingExcludes&amp;gt;WEB-INF/lib/persistence-1.0-SNAPSHOT.jar&amp;lt;/packagingExcludes&amp;gt;
                        &amp;lt;/configuration&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&amp;lt;/profile&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Then you will get both of artifacts installed after issuing &lt;code&gt;mvn clean install -P prod&lt;/code&gt; as follows:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ unzip -l /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT.war | grep persistence
     3521  03-20-15 14:25   WEB-INF/lib/persistence-1.0-SNAPSHOT.jar
$ unzip -l /Users/kyle/.m2/repository/org/nailedtothex/examples/classifier/web/1.0-SNAPSHOT/web-1.0-SNAPSHOT-prod.war | grep persistence
     3513  03-20-15 14:25   WEB-INF/lib/persistence-1.0-SNAPSHOT-prod.jar&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_references&quot;&gt;References&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;ulist&quot;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;http://stackoverflow.com/questions/12320322/build-multiple-artifacts-with-different-classifiers-at-once&quot; class=&quot;bare&quot;&gt;http://stackoverflow.com/questions/12320322/build-multiple-artifacts-with-different-classifiers-at-once&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;http://stackoverflow.com/questions/11779319/how-to-release-a-multimodule-project-with-a-classifier&quot; class=&quot;bare&quot;&gt;http://stackoverflow.com/questions/11779319/how-to-release-a-multimodule-project-with-a-classifier&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;http://www.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/&quot; class=&quot;bare&quot;&gt;http://www.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;http://maven.apache.org/guides/mini/guide-building-for-different-environments.html&quot; class=&quot;bare&quot;&gt;http://maven.apache.org/guides/mini/guide-building-for-different-environments.html&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">https://nozaki.me/roller/kyle/entry/an-example-of-maven-ear</guid>
    <title>An example of Maven EAR project consists of an EJB interface, an EJB implementation and a WAR</title>
    <dc:creator>Kohei Nozaki</dc:creator>
    <link>https://nozaki.me/roller/kyle/entry/an-example-of-maven-ear</link>
        <pubDate>Fri, 6 Mar 2015 13:43:28 +0000</pubDate>
    <category>Maven</category>
    <category>ear</category>
    <category>ejb</category>
    <category>intellij</category>
    <category>javaee</category>
    <category>maven</category>
            <description>&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;The project consists of following principal modules:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;ulist&quot;&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;eartest-ejb-api: holds an EJB local interface named &lt;code&gt;Hello&lt;/code&gt;. packaging=jar. no dependency.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;eartest-ejb-impl: holds an EJB implementation named &lt;code&gt;HelloImpl&lt;/code&gt; which implements &lt;code&gt;Hello&lt;/code&gt;. packaging=ejb. depends on eartest-ejb-api.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;eartest-war: holds an Servlet which has an injection point of &lt;code&gt;Hello&lt;/code&gt; interface. depends on eartest-ejb-api.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;eartest-ear: holds above 3 modules in the EAR.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Whole project is can be obtained from &lt;a href=&quot;https://github.com/lbtc-xxx/eartest&quot; class=&quot;bare&quot;&gt;https://github.com/lbtc-xxx/eartest&lt;/a&gt; .&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_structure_of_eartest_ear_module&quot;&gt;Structure of eartest-ear module&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ tree eartest-ear/target/eartest-ear
eartest-ear/target/eartest-ear
|-- META-INF
|   `-- application.xml
|-- eartest-ejb-impl-1.0-SNAPSHOT.jar
|-- eartest-war-1.0-SNAPSHOT.war
`-- lib
    `-- eartest-ejb-api-1.0-SNAPSHOT.jar

2 directories, 4 files&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_structure_of_eartest_war_module&quot;&gt;Structure of eartest-war module&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ tree eartest-war/target/eartest-war
eartest-war/target/eartest-war
|-- META-INF
`-- WEB-INF
    `-- classes
        `-- eartest
            `-- war
                `-- MyServlet.class

5 directories, 1 file&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;MyServlet can reference &lt;code&gt;eartest-ejb-api-1.0-SNAPSHOT.jar&lt;/code&gt; because it&amp;#8217;s placed under &lt;code&gt;lib&lt;/code&gt; directory in the parent EAR. this packaging style is called as Skinny WAR.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_structure_of_eartest_ejb_api&quot;&gt;Structure of eartest-ejb-api&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ tree eartest-ejb-api/target/classes
eartest-ejb-api/target/classes
`-- eartest
    `-- ejb
        `-- api
            `-- Hello.class

3 directories, 1 file&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_structure_of_eartest_ejb_impl&quot;&gt;Structure of eartest-ejb-impl&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ tree eartest-ejb-impl/target/classes
eartest-ejb-impl/target/classes
|-- META-INF
|   `-- ejb-jar.xml
`-- eartest
    `-- ejb
        `-- impl
            `-- HelloImpl.class

4 directories, 2 files&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;sect1&quot;&gt;
&lt;h2 id=&quot;_a_problem_with_intellij_idea&quot;&gt;A problem with IntelliJ IDEA&lt;/h2&gt;
&lt;div class=&quot;sectionbody&quot;&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;IntelliJ has an annoying issue: &lt;a href=&quot;https://youtrack.jetbrains.com/issue/IDEA-97324&quot;&gt;Maven support cannot handle skinny wars for EAR deployments : IDEA-97324&lt;/a&gt;. this brings unnecessary eartest-ejb-api into &lt;code&gt;WEB-INF/lib&lt;/code&gt; inside the WAR and brings following exception. to avoid this, I need to put &lt;code&gt;&amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;/code&gt; in dependency declaration for &lt;code&gt;eartest-ejb-api&lt;/code&gt; in &lt;code&gt;pom.xml&lt;/code&gt; of &lt;code&gt;eartest-war&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
	at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:162)
	at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133)
	at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89)
	at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:149)
	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$5.createInstance(UndertowDeploymentInfoService.java:1233)
	at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:215) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	... 27 more
Caused by: java.lang.IllegalArgumentException: Can not set eartest.ejb.api.Hello field eartest.war.MyServlet.hello to eartest.ejb.api.Hello$$$view17
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) [rt.jar:1.8.0_20]
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) [rt.jar:1.8.0_20]
	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.8.0_20]
	at java.lang.reflect.Field.set(Field.java:758) [rt.jar:1.8.0_20]
	at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:108)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45) [wildfly-ee-8.2.0.Final.jar:8.2.0.Final]
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
	at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
	at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
	at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
	at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)
	... 32 more&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description>          </item>
    <item>
    <guid isPermaLink="true">https://nozaki.me/roller/kyle/entry/getting-dependencies-with-maven-dependency</guid>
    <title>Getting dependencies with Maven dependency plugin</title>
    <dc:creator>Kohei Nozaki</dc:creator>
    <link>https://nozaki.me/roller/kyle/entry/getting-dependencies-with-maven-dependency</link>
        <pubDate>Fri, 27 Feb 2015 02:30:52 +0000</pubDate>
    <category>Maven</category>
    <category>maven</category>
            <description>&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;I want to get all of dependencies of:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.jboss.as&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;jboss-as-controller-client&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;7.2.0.Final&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;So, create &lt;code&gt;pom.xml&lt;/code&gt; as follows:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&amp;gt;
    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;

    &amp;lt;groupId&amp;gt;org.nailedtothex&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;get-dependencies&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.jboss.as&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;jboss-as-controller-client&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;7.2.0.Final&amp;lt;/version&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

&amp;lt;/project&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Then issue:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ mvn dependency:copy-dependencies&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;paragraph&quot;&gt;
&lt;p&gt;Then you will get:&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;literalblock&quot;&gt;
&lt;div class=&quot;content&quot;&gt;
&lt;pre&gt;$ ls -l target/dependency/
total 2824
-rw-r--r--+ 1 kyle  staff    3933 Feb 27 11:25 jboss-as-build-config-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff  177511 Feb 27 11:25 jboss-as-controller-client-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff   96612 Feb 27 11:25 jboss-as-protocol-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff   92053 Feb 27 11:25 jboss-dmr-1.1.6.Final.jar
-rw-r--r--+ 1 kyle  staff   55248 Feb 27 11:25 jboss-logging-3.1.2.GA.jar
-rw-r--r--+ 1 kyle  staff  229373 Feb 27 11:25 jboss-marshalling-1.3.16.GA.jar
-rw-r--r--+ 1 kyle  staff  238355 Feb 27 11:25 jboss-remoting-3.2.14.GA.jar
-rw-r--r--+ 1 kyle  staff   89315 Feb 27 11:25 jboss-sasl-1.0.3.Final.jar
-rw-r--r--+ 1 kyle  staff  119912 Feb 27 11:25 jboss-threads-2.1.0.Final.jar
-rw-r--r--+ 1 kyle  staff  241808 Feb 27 11:25 xnio-api-3.0.7.GA.jar
-rw-r--r--+ 1 kyle  staff   80070 Feb 27 11:25 xnio-nio-3.0.7.GA.jar
$&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;</description>          </item>
  </channel>
</rss>