title: maven profile conditional dependency
body: <p>I have a pom file where I have 1 conditional dependency and a number of other dependencies which are not conditional (i.e. I want those dependencies to exist for both profiles). </p>
  
  <p>The condition is whether or not I am deploying on tomcat or websphere so I have named my maven profiles accordingly. </p>
  
  <p>My question is how can I make just that single dependency conditional based on my profile and the other dependencies exist for both profiles? </p>
  
  <p>I had a shot at it and have pasted what I have attempted below but what I have doesn't seem to be working. Would welcome some feedback.</p>
  
  <p>thanks</p>
  
  <pre><code>&lt;!-- tried to put the conditional dependencies in the profile section --&gt;
  &lt;profiles&gt;
      &lt;profile&gt;
      &lt;id&gt;tomcat&lt;/id&gt;
      &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                  &lt;artifactId&gt;jstl&lt;/artifactId&gt;
                  &lt;version&gt;1.2&lt;/version&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
      &lt;/dependencyManagement&gt;
      &lt;activation&gt;
          &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
      &lt;/activation&gt;        
      &lt;/profile&gt;
      &lt;profile&gt;
       &lt;id&gt;websphere&lt;/id&gt;
       &lt;dependencyManagement&gt;
          &lt;dependencies&gt;
              &lt;dependency&gt;
                  &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
                  &lt;artifactId&gt;jstl&lt;/artifactId&gt;
                  &lt;version&gt;1.2&lt;/version&gt;
                  &lt;scope&gt;provided&lt;/scope&gt;
              &lt;/dependency&gt;
          &lt;/dependencies&gt;
       &lt;/dependencyManagement&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  
  &lt;!-- then list all other non-conditional dependencies --&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      ...
      ...
  &lt;/dependencies&gt;
  </code></pre>