maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lennart Jörelid <lennart.jore...@gmail.com>
Subject Re: Re[2]: Configurable Dependencies for Maven Plugins?
Date Wed, 12 Apr 2017 20:05:31 GMT
Hello Dirk,

There are always options for doing this, although they may not be
considered elegant.

To solve your problem in a practical way I would recommend defining two
profiles within your pom (say "neo4jV2" and "neo4jV3").
One of the properties should be included ("Conditional profiles") using the
value (or existence/non-existence) of a command-line property (typically
something like -Dneo4jVersion=2).

The neo4jv2 profile includes the three neo4j2 dependencies, and the neo4jv3
profile includes the two neo4j3 dependencies.
Include the neo4jV3 profile unless the property "neo4jVersion" is set on
the command line.

Done.


2017-04-12 21:50 GMT+02:00 Dirk Mahler <dirk.mahler@buschmais.com>:

> Hi Stephen,
>
> I need to declare the dependency to static directly, so I'm on the
> Sorry-Out-Of-Luck path...
>
> But your suggestion makes me  thinking of providing an artifact myself
> (just pom packaging) in two different versions that pulls in the different
> dependencies and which can be overridden by the user. This should be
> possible then, right?
>
> In that case I have to think about how to organize my own builds because I
> assume that within one reactor I won't be able to build two modules with
> same groupId and artifactId but different versions.
>
> Cheers,
>
> Dirk
>
> PS: Thanks for the 3.5.0 release, works like a charm for me!
>
> Am Mittwoch 12. April 2017 schrieb Stephen Connolly:
> > On Wed 12 Apr 2017 at 20:21, Dirk Mahler <dirk.mahler@buschmais.com>
> wrote:
> >
> > > Hi Bindul,
> > >
> > > sadly it's not that easy (or it's so easy that I don't see the
> > > solution...). As a default and for compatibility reasons I'd like to
> > > declare the dependencies of the Neo4j 2.x artifacts for my Maven
> plugin:
> > >
> > > - org.neo4j:neoj
> > > - org.neo4j.app:neo4j-server
> > > - org.neo4j.app:neo4j-server:static *
> >
> >
> > Do you declare a direct dependency on static or a transitive one?
> >
> > If direct, then yes you are Sorry-out-of-Luck
> >
> > If transitive, then the <dependency> in the user's <plugin> will override
> > the neo4j-server and you are sorted as the newer version will not pull in
> > the static stuff
> >
> > >
> > >
> > > For a user it would be possible to override only the first two
> > > dependencies with the Neo4j 3.x versions: the third artifact (*) does
> > > not exist for Neo4j 3.x (the Neo guys merged the static content into
> > > neo4j-server.jar, i.e. into the main artifact without classifier). In
> > > this case I would need to exclude "org.neo4j.app:neo4j-server:static"
> > > which is still there as a 2.x artifact and pulls in some other deps
> that
> > > are conflicting with the 3.x stuff. Any idea?
> > >
> > > Cheers,
> > >
> > > Dirk
> > >
> > > ------ Originalnachricht ------
> > > Von: "Bindul Bhowmik" <bindulbhowmik@gmail.com>
> > > An: "Maven Developers List" <dev@maven.apache.org>; "Dirk Mahler"
> > > <dirk.mahler@buschmais.com>
> > > Gesendet: 12.04.2017 20:28:16
> > > Betreff: Re: Configurable Dependencies for Maven Plugins?
> > >
> > > >Dirk,
> > > >
> > > >On Wed, Apr 12, 2017 at 7:06 AM, Dirk Mahler
> > > ><dirk.mahler@buschmais.com> wrote:
> > > >>  Hi all,
> > > >>
> > > >>  is there a way to provide users of a plugin a way of easily
> switching
> > > >>  dependencies of it?
> > > >>
> > > >>  Background: I'm developing a Maven plugin (jQAssistant) that comes
> > > >>with a
> > > >>  dependency to Neo4j (graph database). Currently I'm using Neo4j
> 2.3.x
> > > >>which
> > > >>  has been compiled against Java 7 but I would like to offer users
of
> > > >>the
> > > >>  Maven plugin an easy option to use the newer Neo4j 3.x releases
> which
> > > >>offer
> > > >>  some new features but require Java 8.
> > > >>
> > > >>  I know that it's possible to overwrite an existing dependency for
a
> > > >>plugin,
> > > >>  e.g.
> > > >>
> > > >>  <plugin>
> > > >>    <groupId>com.buschmais.jqassistant</groupId>
> > > >>    <artifactId>jqassistant-maven-plugin</artifactId>
> > > >>    <version>1.3.0</version>
> > > >>    <dependencies>
> > > >>      <dependency>
> > > >>        <groupId>org.neo4j</groupId>
> > > >>        <artifactId>neo4j</artifactId>
> > > >>        <version>3.1.3</version> <!-- instead of the
default 2.3.10
> -->
> > > >>      </dependency>
> > > >>    </dependencies>
> > > >>  </plugin>
> > > >
> > > >As long as your code can handle the different versions of the
> > > >dependency, I think this is absolutely doable. In fact the Maven
> > > >Checkstyle Plugin uses the same approach to allow upgrading checkstyle
> > > >versions without upgrading the plugin version [1].
> > > >
> > > >>
> > > >>  The problem is that in my case the old version comes with another
> set
> > > >>of
> > > >>  dependencies than the new one:
> > > >
> > > >I do not think this will be a problem.
> > > >
> > > >>
> > > >>  old:
> > > >>
> > > >>  <dependencies>
> > > >>       <dependency>
> > > >>           <groupId>org.neo4j</groupId>
> > > >>           <artifactId>neo4j</artifactId>
> > > >>           <version>2.3.10</version>
> > > >>       </dependency>
> > > >>       <dependency>
> > > >>           <groupId>org.neo4j.app</groupId>
> > > >>           <artifactId>neo4j-server</artifactId>
> > > >>           <version>2.3.10</version>
> > > >>       </dependency>
> > > >>       <dependency>
> > > >>           <groupId>org.neo4j.app</groupId>
> > > >>           <artifactId>neo4j-server</artifactId>
> > > >>           <classifier>static-web</classifier>
> > > >>           <version>2.3.10</version>
> > > >>       </dependency>
> > > >>  </dependencies>
> > > >>
> > > >>  new:
> > > >>
> > > >>  <dependencies>
> > > >>       <dependency>
> > > >>           <groupId>org.neo4j</groupId>
> > > >>           <artifactId>neo4j</artifactId>
> > > >>           <version>3.1.3</version>
> > > >>       </dependency>
> > > >>       <dependency>
> > > >>           <groupId>org.neo4j.app</groupId>
> > > >>           <artifactId>neo4j-server</artifactId>
> > > >>           <version>3.1.3</version>
> > > >>       </dependency>
> > > >>  </dependencies>
> > > >>
> > > >>  Is there a good way to deal with it such that a user of the
> > > >>  jqassistant-maven-plugin can easily switch between both variants?
> > > >>
> > > >>  Cheers,
> > > >>
> > > >>  Dirk
> > > >>
> > > >>  Senior Consultant IT
> > > >>  buschmais GbR
> > > >
> > > >
> > > >- Bindul
> > > >
> > > >[1]
> > > >
> > > http://maven.apache.org/plugins/maven-checkstyle-
> plugin/examples/upgrading-checkstyle.html
> > > >
> > > >>
> > > >>  -----------------------------------------------------------------
> > > >>  Inhaber Torsten Busch, Frank Schwarz, Dirk Mahler, Tobias Israel
> > > >>  Adresse buschmais GbR, Leipziger Straße 93, 01127 Dresden
> > > >>  Telefon  +49 (0) 351 3209 23-0
> > > >>  Fax      +49 (0) 351 3209 23-29
> > > >>  Mobil    +49 (0) 177 3137411
> > > >>  E-Mail   dirk.mahler@buschmais.com
> > > >>  Internet http://www.buschmais.de
> > > >>  -----------------------------------------------------------------
> > > >>
> > > >>  Diese E-Mail enthält vertrauliche undoder rechtlich geschützte
> > > >>  Informationen. Wenn Sie diese E-Mail irrtümlich erhalten haben,
> > > >>  bitten wir Sie diese E-Mail umgehend zu löschen. Das unerlaubte
> > > >>  Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht
> > > >>  gestattet.
> > > >>
> > > >>  This e-mail may contain confidential or privileged information. If
> > > >>  you are not the intended recipient we kindly request you to delete
> > > >>  this e-mail immediately. Any unauthorized copying, disclosure or
> > > >>  distribution of the material in this e-mail is strictly forbidden.
> > > >>
> > > >>
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > >For additional commands, e-mail: dev-help@maven.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> > > --
> > Sent from my phone
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 

--
+==============================+
| Bästa hälsningar,
| [sw. "Best regards"]
|
| Lennart Jörelid
| EAI Architect & Integrator
|
| jGuru Europe AB
| Mölnlycke - Kista
|
| Email: lj@jguru.se
| URL:   www.jguru.se
| Phone
| (skype):    jgurueurope
| (intl):     +46 708 507 603
| (domestic): 0708 - 507 603
+==============================+

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message