You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Scott Maines <sm...@alaya.com> on 2009/03/05 05:03:24 UTC

Two issues: goals do not bind, JUnit annotations seem not to work

======= Two issues with Maven, perhaps pilot error

I have two issues at the moment,

* Goals do not seem to bind to phases as I expect
* Annotations in JUnit do not seem to be executing at all

The things which do not seem to work are so basic that I'm thinking the
problems are local to me, and I need additional insight. Please let me 
know what I am missing here.  I am using the Maven 2.0.9 distribution
under Fedora 9 with no settings file [since tried Maven 2.0.10 and
2.1.0-M1 as well].

For those who would like to see the POM,  I've inlined it below the
signature.


======= Issue 1: goals do not seem to bind to phases

I believe my pluginManagement section (see POM) should allow me to say,

$ mvn clean test

...and have aspects woven into the result.  As it turns out, AspectJ
only works when I say,

$ mvn clean aspectj:compile aspectj:test-compile test

...or even...

$ mvn clean aspectj:compile test

...and when it does so, it references in the output the ids of the
executions I configured in the POM,

[INFO] [aspectj:compile]
[INFO] [aspectj:test-compile]
[INFO] [aspectj:compile {execution: aspectj-compile}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: aspectj-test-compile}]

Also, I wonder whether, if the AspectJ goals were binding correctly to
phases, I would see them here,

$ mvn help:describe -Dcmd=process-sources
...
[INFO] 'process-sources' is a phase corresponding to this plugin:

It is a part of the lifecycle for the POM packaging 'jar'. This
lifecycle includes the following phases:
* validate: Not defined
* initialize: Not defined
* generate-sources: Not defined
* process-sources: Not defined
* generate-resources: Not defined
* process-resources:
org.apache.maven.plugins:maven-resources-plugin:resources
* compile: org.apache.maven.plugins:maven-compiler-plugin:compile
* process-classes: Not defined
* generate-test-sources: Not defined
* process-test-sources: Not defined
* generate-test-resources: Not defined
* process-test-resources:
org.apache.maven.plugins:maven-resources-plugin:testResources
* test-compile: org.apache.maven.plugins:maven-compiler-plugin:testCompile
* process-test-classes: Not defined
* test: org.apache.maven.plugins:maven-surefire-plugin:test
* package: org.apache.maven.plugins:maven-jar-plugin:jar
* pre-integration-test: Not defined
* integration-test: Not defined
* post-integration-test: Not defined
* verify: Not defined
* install: org.apache.maven.plugins:maven-install-plugin:install
* deploy: org.apache.maven.plugins:maven-deploy-plugin:deploy


======= Issue 2: annotations in JUnit do not seem to be executing at all

The tests all function as though the JUnit annotations I used, @Test and
@Before, are not there, though the compiler
seems to process them, and complain if they are incorrectly included.
The versions I configured I think should allow
for annotations. See POM below for version numbers.


Finally,...

This is my first post to this list, please pardon any inadvertent breach
of process or etiquette.

Thanks in advance,

-SM

======= Inlined POM

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.alaya.test</groupId>
  <artifactId>test-goal-bind</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>test-goal-bind</name>

     <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>1.6.2</version>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                 <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-help-plugin</artifactId>
                    <configuration>
                        <detail>true</detail>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.4.3</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${source-jdk}</source>
                        <target>${source-jdk}</target>
                        <debug>true</debug>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>aspectj-compile</id>
                            <phase>process-sources</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>aspectj-test-compile</id>
                            <phase>process-test-sources</phase>
                            <goals>
                                <goal>test-compile</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                      <source>${source-jdk}</source>
                      <target>${source-jdk}</target>
                      <complianceLevel>${source-jdk}</complianceLevel>
                      <verbose>true</verbose>
                      <weaveMainSourceFolder>true</weaveMainSourceFolder>
                      <showWeaveInfo>true</showWeaveInfo>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <properties>
        <source-jdk>1.6</source-jdk>
     </properties>
</project>





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


Re: Two issues: goals do not bind, JUnit annotations seem not to work

Posted by smaines <sm...@alaya.com>.
I have since resolved Issue 2: JUnit annotations do not work.  I am not sure
of why, but when I removed the explicit surefire plugin configuration, it
stopped pulling in JUnit 3.8 in strange places, though it still seems to use
JUnit 4.0 in places instead of JUnit 4.5, which I list as a dependency.

All is, for now, right with the world,

-SM

-- 
View this message in context: http://www.nabble.com/Two-issues%3A-goals-do-not-bind%2C-JUnit-annotations-seem-not-to-work-tp22345517p22367672.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: Two issues: goals do not bind, JUnit annotations seem not to work

Posted by smaines <sm...@alaya.com>.

Wayne Fay wrote:
> 
>> I believe my pluginManagement section (see POM) should allow me to say,
>> ...and have aspects woven into the result.  As it turns out, AspectJ
>> only works when I say,
> 
> pluginManagement is not actually used during the build in the way you
> believe....
> 
> I'd be curious why you came to the assumption that configuring things
> in pluginMgmt was sufficient to get the plugins to execute during the
> build. You're not the first newbie with this belief, and I'm wondering
> where the documentation needs to be improved to avoid this in the
> future.
> 
> Wayne
> 
> 

Thanks for the sanity check.  Once I deleted the pluginManagement tags (open
and close), all behaved as one would expect, though JUnit annotations still
do not seem to work.

The whole pluginManagement thing is a bit counter-intuitive on a few levels. 
I have sent you under separate cover some thoughts on why this might be so,
though I hasten to stress that the error itself was, as expected, entirely
my own.

Thanks again,

-SM

P.S. JUnit annotations, any thoughts?

-- 
View this message in context: http://www.nabble.com/Two-issues%3A-goals-do-not-bind%2C-JUnit-annotations-seem-not-to-work-tp22345517p22348314.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: Two issues: goals do not bind, JUnit annotations seem not to work

Posted by Wayne Fay <wa...@gmail.com>.
> I believe my pluginManagement section (see POM) should allow me to say,
> ...and have aspects woven into the result.  As it turns out, AspectJ
> only works when I say,

pluginManagement is not actually used during the build in the way you
believe. It simply stores your plugin configuration, so you could eg
share the same config across multiple uses of a plugin in various
modules using a shared parent pom.

You still need to declare the actual plugins in the <build><plugins>
section of your project. You should only have to declare group,
artifact, and version in <plugins> assuming you have the rest of the
config declared in pluginMgmt.

I'd be curious why you came to the assumption that configuring things
in pluginMgmt was sufficient to get the plugins to execute during the
build. You're not the first newbie with this belief, and I'm wondering
where the documentation needs to be improved to avoid this in the
future.

Wayne

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