It seems that AJDT tries to weave all classes in a project by default.

I attached files in a test project.

When I use "call" for pointcuts of interface Addable in MyAspect, AJDT tries
to weave the interface calls of the mock object. Sometimes I don't want the
advices in my unit test code, for example, advices from the log aspect.

How can I prevent AJDT from weaving junit test case classes?

I did a test in my Eclipse 3.5 with AJDT 2.0.2.

If I add aop.xml into project properties->AspectJ Builder->aop.xml
Management, some wired things happens:

   1. all aspectj advice markers are gone. You need to clean the project
   first, otherwise you may see the markers are still there.
   2. if you clean the project "Project->clean...", only the files under
   src/main/java are compiled, src/test/java are not compiled.
   3. remove aop.xml from aop.xml management, everything comes back.

What's wrong in my project? Is this AJDT bug?

Thanks.

Ben
<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.foo</groupId>
	<artifactId>bar</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>AJDT weaving test</name>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.7</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.easymock</groupId>
			<artifactId>easymock</artifactId>
			<version>2.5.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>1.6.8</version>
		</dependency>

	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-eclipse-plugin</artifactId>
				<version>2.7</version>
				<configuration>
					<additionalBuildcommands>
						<buildCommand>
							<name>org.eclipse.ajdt.core.ajbuilder</name>
						</buildCommand>
					</additionalBuildcommands>
					<additionalProjectnatures>
						<projectnature>org.eclipse.ajdt.ui.ajnature</projectnature>
					</additionalProjectnatures>
				</configuration>
			</plugin>
		</plugins>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
		</testResources>
	</build>
</project>

Attachment: AjdtWeavingTest.java
Description: Binary data

Attachment: MyAspect.java
Description: Binary data

Attachment: Addable.java
Description: Binary data

Attachment: AjdtWeaving.java
Description: Binary data

<?xml version="1.0" encoding="UTF-8"?>
<aspectj>
    <aspects>
        <aspect name="com.foo.bar.Test.MyAspect"/>
    </aspects>
    
    <weaver>
        <include name="com.foo.bar.Test.*"/>
    </weaver>
</aspectj>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to