You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Dean Schulze <de...@gmail.com> on 2017/01/13 16:43:47 UTC

Is there a way to make mvn default to Java 8?

I would like to avoid having to add

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

to every pom.xml.  Is there a global setting I can set in mvn to make Java
8 the default so I don't have to add this to every pom.xml?

Re: Is there a way to make mvn default to Java 8?

Posted by Laird Nelson <lj...@gmail.com>.
On Fri, Jan 13, 2017 at 8:51 AM Dean Schulze <de...@gmail.com>
wrote:

> I would like to avoid having to add
>
> <properties>
> <maven.compiler.source>1.8</maven.compiler.source>
> <maven.compiler.target>1.8</maven.compiler.target>
> </properties>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make Java
> 8 the default so I don't have to add this to every pom.xml?
>

Like others on the list, I recommend you use a common parent pom, since
these settings are part of the reproducibility of your build.  If for some
reason you're not going to do that, then I suppose you can add
-Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8 to MAVEN_OPTS in
your ~/.mavenrc file (which does not appear to be listed here:
http://maven.apache.org/configure.html, but definitely is consulted as part
of overall Maven configuration at startup).

(Of course if I or others consume your pom.xml we have no idea what version
of Java we're supposed to use.)

Best,
Laird

Re: Is there a way to make mvn default to Java 8?

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
It is no problem if you have installed multiple JVMs, maven only knows about the current java version used to start it or if you explicitly specify executables or toolchains. (Some POMs like Apache Commons defines profiles using environment variables like JAVA_1_8_HOME)
Anyway, on your system you can test it, if you do not specify source or target versions it will default to the start-jvm (which is not good for having stable and repeatable builds)
Gruss
Bernd
-- 
http://bernd.eckenfels.net




On Fri, Jan 13, 2017 at 6:15 PM +0100, "John Patrick" <nh...@gmail.com> wrote:










If you only have Java 8 installed, would that work? Or does target
still default to something older? I've got Java 7, 8 and 9 on my
machine so can't easily test myself.


On 13 January 2017 at 17:04, Chris Barlock  wrote:
> Most projects I've been on have a notion of a "parent" or "common" script
> (whether Ant, Maven or just about anything else).  With Maven, you could
> define a  POM that contains all the common stuff.  Of course, you
> would have to add the parent element to all child POMs, but if you ever
> want to change something in the parent (such as this Java version), you
> would only have to do it once.
>
> Chris
>
>
>
>
> From:   Dean Schulze 
> To:     users@maven.apache.org
> Date:   01/13/2017 11:51 AM
> Subject:        Is there a way to make mvn default to Java 8?
>
>
>
> I would like to avoid having to add
>
> 
> 1.8
> 1.8
> 
>
> to every pom.xml.  Is there a global setting I can set in mvn to make Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org







Re: Is there a way to make mvn default to Java 8?

Posted by Mark Prins <mc...@gmail.com>.
Op 13 jan. 2017 18:15 schreef "John Patrick" <nh...@gmail.com>:

If you only have Java 8 installed, would that work? Or does target
still default to something older?


The default value for the compiler plugin is 1.5 even when using java 8
runtime.
You may want to look into toolchains as well.

Re: Is there a way to make mvn default to Java 8?

Posted by John Patrick <nh...@gmail.com>.
If you only have Java 8 installed, would that work? Or does target
still default to something older? I've got Java 7, 8 and 9 on my
machine so can't easily test myself.


On 13 January 2017 at 17:04, Chris Barlock <ba...@us.ibm.com> wrote:
> Most projects I've been on have a notion of a "parent" or "common" script
> (whether Ant, Maven or just about anything else).  With Maven, you could
> define a <parent> POM that contains all the common stuff.  Of course, you
> would have to add the parent element to all child POMs, but if you ever
> want to change something in the parent (such as this Java version), you
> would only have to do it once.
>
> Chris
>
>
>
>
> From:   Dean Schulze <de...@gmail.com>
> To:     users@maven.apache.org
> Date:   01/13/2017 11:51 AM
> Subject:        Is there a way to make mvn default to Java 8?
>
>
>
> I would like to avoid having to add
>
> <properties>
> <maven.compiler.source>1.8</maven.compiler.source>
> <maven.compiler.target>1.8</maven.compiler.target>
> </properties>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Is there a way to make mvn default to Java 8?

Posted by Chris Barlock <ba...@us.ibm.com>.
Most projects I've been on have a notion of a "parent" or "common" script 
(whether Ant, Maven or just about anything else).  With Maven, you could 
define a <parent> POM that contains all the common stuff.  Of course, you 
would have to add the parent element to all child POMs, but if you ever 
want to change something in the parent (such as this Java version), you 
would only have to do it once.

Chris




From:   Dean Schulze <de...@gmail.com>
To:     users@maven.apache.org
Date:   01/13/2017 11:51 AM
Subject:        Is there a way to make mvn default to Java 8?



I would like to avoid having to add

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

to every pom.xml.  Is there a global setting I can set in mvn to make Java
8 the default so I don't have to add this to every pom.xml?





RE: Is there a way to make mvn default to Java 8?

Posted by Wouter Lievens <wo...@ams.com>.
No it doesn't necessarily. We use parent poms all the time, but without the module feature.


-----Original Message-----
From: Dean Schulze [mailto:dean.w.schulze@gmail.com] 
Sent: Friday, January 13, 2017 6:01 PM
To: Maven Users List <us...@maven.apache.org>
Subject: Re: Is there a way to make mvn default to Java 8?

That means making every new project a module of that parent.  Ugh.

On Fri, Jan 13, 2017 at 9:54 AM, Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:

> Sorry when this answer is an over-simplification, but you can just 
> configure it in a common parent. This is a quite typical case why you 
> want shared company/team/product/buildenv parents.
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
>
>
>
>
> On Fri, Jan 13, 2017 at 5:51 PM +0100, "Dean Schulze" < 
> dean.w.schulze@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> I would like to avoid having to add
>
>
> 1.8
> 1.8
>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make 
> Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>
>
>

Re: Is there a way to make mvn default to Java 8?

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
No, you only need to point to an installed parent project, it does not have to be an aggregator.

Gruss
Bernd
-- 
http://bernd.eckenfels.net




On Fri, Jan 13, 2017 at 6:00 PM +0100, "Dean Schulze" <de...@gmail.com> wrote:










That means making every new project a module of that parent.  Ugh.

On Fri, Jan 13, 2017 at 9:54 AM, Bernd Eckenfels 
wrote:

> Sorry when this answer is an over-simplification, but you can just
> configure it in a common parent. This is a quite typical case why you want
> shared company/team/product/buildenv parents.
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
>
>
>
>
> On Fri, Jan 13, 2017 at 5:51 PM +0100, "Dean Schulze" <
> dean.w.schulze@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> I would like to avoid having to add
>
>
> 1.8
> 1.8
>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>
>
>






Re: Is there a way to make mvn default to Java 8?

Posted by Chris Barlock <ba...@us.ibm.com>.
Maybe...Depends on what you mean by "a module of that parent."  If you 
mean

<modules>
  <module>...</module>
  <module>...</module>
</modules>

then I think not.  I think it means that every POM that wants to use the 
same common stuff would include something like:

        <parent>
                <groupId>my.groupId</groupId>
                <artifactId>build.master</artifactId>
                <version>1.0.0.0-SNAPSHOT</version>
                <relativePath>../build.master</relativePath>
        </parent>

Chris




From:   Dean Schulze <de...@gmail.com>
To:     Maven Users List <us...@maven.apache.org>
Date:   01/13/2017 01:14 PM
Subject:        Re: Is there a way to make mvn default to Java 8?



That means making every new project a module of that parent.  Ugh.

On Fri, Jan 13, 2017 at 9:54 AM, Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:

> Sorry when this answer is an over-simplification, but you can just
> configure it in a common parent. This is a quite typical case why you 
want
> shared company/team/product/buildenv parents.
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
>
>
>
>
> On Fri, Jan 13, 2017 at 5:51 PM +0100, "Dean Schulze" <
> dean.w.schulze@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> I would like to avoid having to add
>
>
> 1.8
> 1.8
>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make 
Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>
>
>





Re: Is there a way to make mvn default to Java 8?

Posted by Dean Schulze <de...@gmail.com>.
That means making every new project a module of that parent.  Ugh.

On Fri, Jan 13, 2017 at 9:54 AM, Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:

> Sorry when this answer is an over-simplification, but you can just
> configure it in a common parent. This is a quite typical case why you want
> shared company/team/product/buildenv parents.
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
>
>
>
>
> On Fri, Jan 13, 2017 at 5:51 PM +0100, "Dean Schulze" <
> dean.w.schulze@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
> I would like to avoid having to add
>
>
> 1.8
> 1.8
>
>
> to every pom.xml.  Is there a global setting I can set in mvn to make Java
> 8 the default so I don't have to add this to every pom.xml?
>
>
>
>
>
>

Re: Is there a way to make mvn default to Java 8?

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Sorry when this answer is an over-simplification, but you can just configure it in a common parent. This is a quite typical case why you want shared company/team/product/buildenv parents.

Gruss
Bernd
-- 
http://bernd.eckenfels.net




On Fri, Jan 13, 2017 at 5:51 PM +0100, "Dean Schulze" <de...@gmail.com> wrote:










I would like to avoid having to add


1.8
1.8


to every pom.xml.  Is there a global setting I can set in mvn to make Java
8 the default so I don't have to add this to every pom.xml?