You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by hujirong <ji...@gmail.com> on 2012/05/23 01:59:59 UTC

Feel Maven is not intuitive

Hi

After working with Maven for a month, I am still not quite understand how
Maven works. Maybe just like Microsoft technologies, encapsulate too much.
One key issue is to understand the plugin.

For example, the following example, how can I see this thing allows JDK 5.0
source. There is nowhere it says "allow". How do I know if it's not asking
the compiler to use JDK 5.0?!

So what shall I do to make me clearly understand how plugin in Maven work?

Thanks
Jirong

http://maven.apache.org/guides/getting-started/index.html

For this example, we will configure the Java compiler to allow JDK 5.0
sources. This is as simple as adding this to your POM:

...
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.0.2</version>
      <configuration>
        <source>1.5</source>
        <target>1.5</target>
      </configuration>
    </plugin>
  </plugins>
</build>
...


--
View this message in context: http://maven.40175.n5.nabble.com/Feel-Maven-is-not-intuitive-tp5709506.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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


Re: Feel Maven is not intuitive

Posted by Ron Wheeler <rw...@artifact-software.com>.
I would also add the following:
1) Make sure that you have a repo. Maven without a repo is much less 
intuitive.
2) Make sure that your IDE is set up to support Maven so you do not have 
to switch back and forth between your IDE and Maven. We use Eclipse STS 
from Springframework. It comes with Maven fully supported out of the box.
3) RTFM and the Maven books.

Ron

On 23/05/2012 6:24 AM, Graham Leggett wrote:
> On 23 May 2012, at 1:59 AM, hujirong wrote:
>
>> After working with Maven for a month, I am still not quite understand how
>> Maven works. Maybe just like Microsoft technologies, encapsulate too much.
>> One key issue is to understand the plugin.
> The way to think of maven is:
>
> "maven knows how to do stuff".
>
> Most specifically, each bit of "stuff" that maven knows how to do is implemented by a plugin. For example, maven knows how to compile Java code using the "maven-compiler-plugin". There are a host of other plugins that kick in when you build, each one doing one thing, that runs one after the other as part of a maven lifecycle.
>
> When you come to maven, don't ask the question "how do I...", instead ask the question "how does maven...". The reason the distinction is important is because maven already knows how to do something, you don't need to tell maven what to do, you just need to let maven get on with it.
>
> The vast majority of maven plugins don't need any configuration at all, they just know what to do.
>
>> For example, the following example, how can I see this thing allows JDK 5.0
>> source. There is nowhere it says "allow". How do I know if it's not asking
>> the compiler to use JDK 5.0?!
> The mistake you're making is you're asking the question "how do I allow JDK source", so you're looking for an "allow" option and not finding one.
>
> What you should ask instead is "how does maven control the JDK source", the answer is by the maven-compiler-plugin the minimum levels by setting the following configuration option in the configuration for the maven-compiler-plugin:
>
>>       <configuration>
>>         <source>1.5</source>
>>         <target>1.5</target>
>>       </configuration>
> Regards,
> Graham
> --
>


-- 
Ron Wheeler President Artifact Software Inc email: 
rwheeler@artifact-software.com skype: ronaldmwheeler phone: 
866-970-2435, ext 102

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


Re: Feel Maven is not intuitive

Posted by Graham Leggett <mi...@sharp.fm>.
On 23 May 2012, at 1:59 AM, hujirong wrote:

> After working with Maven for a month, I am still not quite understand how
> Maven works. Maybe just like Microsoft technologies, encapsulate too much.
> One key issue is to understand the plugin.

The way to think of maven is:

"maven knows how to do stuff".

Most specifically, each bit of "stuff" that maven knows how to do is implemented by a plugin. For example, maven knows how to compile Java code using the "maven-compiler-plugin". There are a host of other plugins that kick in when you build, each one doing one thing, that runs one after the other as part of a maven lifecycle.

When you come to maven, don't ask the question "how do I...", instead ask the question "how does maven...". The reason the distinction is important is because maven already knows how to do something, you don't need to tell maven what to do, you just need to let maven get on with it.

The vast majority of maven plugins don't need any configuration at all, they just know what to do.

> For example, the following example, how can I see this thing allows JDK 5.0
> source. There is nowhere it says "allow". How do I know if it's not asking
> the compiler to use JDK 5.0?!

The mistake you're making is you're asking the question "how do I allow JDK source", so you're looking for an "allow" option and not finding one.

What you should ask instead is "how does maven control the JDK source", the answer is by the maven-compiler-plugin the minimum levels by setting the following configuration option in the configuration for the maven-compiler-plugin:

>      <configuration>
>        <source>1.5</source>
>        <target>1.5</target>
>      </configuration>

Regards,
Graham
--


Re: Feel Maven is not intuitive

Posted by John Patrick <nh...@gmail.com>.
Do you specifically want to know about the compile plugin or plugin's
in general.

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
might be a useful site to read.

When helping a new developer understand maven, below is what I go
though with them.

1) Understand maven's lifecycle
2) Understand maven's convention over configuration
3) Check the project package, to understand what lifecycle steps are
activated/used and what plugin's are enabled at each step.
4) Check what properties are active, check parent pom, properties
section, profiles section. I don't configure the compile plugin as the
example you have it just a longer version of setting the properties
maven.compiler.source and maven.compiler.target.
5) Check what plugins are activated, check plugins and
pluginManagement to see what plugin's are configured and what phase
they are configured to execute at. You will need to check the
currently pom and all parent pom's. i.e. our root project pom contains
all version numbers for dependencies, all plugin configuration, so a
sub pom just say use this dependency or plugin and overwrite any
properties as required.

Knowing what each plugin does and how to configure, does rely on those
developers producing accurate documentation and website.

Hope that helps, been using maven since feb 2005, so most things are
habbit now and trained/converted around a 100 developers now to see
the light...

Like Stephen said, the compiler example is just a way of passing the
right flags to javac. Instead of doing "javac -source 1.5 -target 1.6
...".

The plugin naming conversion should help you understand what the
plugin does, that is true for all org.apache.maven.plugins and also I
believe from codehaus, but the wider community can name it anything
they want

Take a made up plugin name called, worktidywrapper. I might have to do
one or more of the following to get it working as required, check the
plugin website if it exists, opening the jar, decompiling the code,
basic repeat execution till it doesn't fail. I might find out a better
name might be, maven-clear-old-snapshots-plugin. It might be a plugin
that removes old snapshots from your local repository because your
work laptop only has a 40GB hard disk and it keeps running out of
space, so they automated the process.

John

On 23 May 2012 01:25, Stephen Connolly <st...@gmail.com> wrote:
> On Wednesday, 23 May 2012, hujirong wrote:
>
>> Hi
>>
>> After working with Maven for a month, I am still not quite understand how
>> Maven works. Maybe just like Microsoft technologies, encapsulate too much.
>> One key issue is to understand the plugin.
>>
>> For example, the following example, how can I see this thing allows JDK 5.0
>> source. There is nowhere it says "allow". How do I know if it's not asking
>> the compiler to use JDK 5.0?!
>
>
> It is saying that the source code obeys 5.0 syntax and to generate byte
> code using 5.0 format.
>
> You can use any JDK >= 5.0 to build... But if using a JDK > 5.0 you will
> likely want to use animal sniffer to enforce the use of only JRE 5.0
> methods if you must be runtime compatible with 5.0 (which is EOL btw)
>
> Not really a Maven thing, more of a java thing
>
>>
>> So what shall I do to make me clearly understand how plugin in Maven work?
>>
>> Thanks
>> Jirong
>>
>> http://maven.apache.org/guides/getting-started/index.html
>>
>> For this example, we will configure the Java compiler to allow JDK 5.0
>> sources. This is as simple as adding this to your POM:
>>
>> ...
>> <build>
>>  <plugins>
>>    <plugin>
>>      <groupId>org.apache.maven.plugins</groupId>
>>      <artifactId>maven-compiler-plugin</artifactId>
>>      <version>2.0.2</version>
>>      <configuration>
>>        <source>1.5</source>
>>        <target>1.5</target>
>>      </configuration>
>>    </plugin>
>>  </plugins>
>> </build>
>> ...
>>
>>
>> --
>> View this message in context:
>> http://maven.40175.n5.nabble.com/Feel-Maven-is-not-intuitive-tp5709506.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
>> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>>
>>

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


Re: Feel Maven is not intuitive

Posted by Stephen Connolly <st...@gmail.com>.
On Wednesday, 23 May 2012, hujirong wrote:

> Hi
>
> After working with Maven for a month, I am still not quite understand how
> Maven works. Maybe just like Microsoft technologies, encapsulate too much.
> One key issue is to understand the plugin.
>
> For example, the following example, how can I see this thing allows JDK 5.0
> source. There is nowhere it says "allow". How do I know if it's not asking
> the compiler to use JDK 5.0?!


It is saying that the source code obeys 5.0 syntax and to generate byte
code using 5.0 format.

You can use any JDK >= 5.0 to build... But if using a JDK > 5.0 you will
likely want to use animal sniffer to enforce the use of only JRE 5.0
methods if you must be runtime compatible with 5.0 (which is EOL btw)

Not really a Maven thing, more of a java thing

>
> So what shall I do to make me clearly understand how plugin in Maven work?
>
> Thanks
> Jirong
>
> http://maven.apache.org/guides/getting-started/index.html
>
> For this example, we will configure the Java compiler to allow JDK 5.0
> sources. This is as simple as adding this to your POM:
>
> ...
> <build>
>  <plugins>
>    <plugin>
>      <groupId>org.apache.maven.plugins</groupId>
>      <artifactId>maven-compiler-plugin</artifactId>
>      <version>2.0.2</version>
>      <configuration>
>        <source>1.5</source>
>        <target>1.5</target>
>      </configuration>
>    </plugin>
>  </plugins>
> </build>
> ...
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/Feel-Maven-is-not-intuitive-tp5709506.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>
>