From f96417c01464907f39ec4435174d09b5c20d2ed3 Mon Sep 17 00:00:00 2001 From: ltheussl Date: Thu, 30 Mar 2006 21:08:35 +0000 Subject: [PATCH] PR: MPASPECTJ-14 Submitted by: Alexey Dashkevich Unable to weave only sources defined in argument files. New property maven.aspectj.src.argfilesOnly. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@390240 13f79535-47bb-0310-9956-ffa450edef68 --- aspectj/plugin.jelly | 10 +++-- aspectj/plugin.properties | 5 +++ aspectj/src/plugin-test/argfile.lst | 3 +- aspectj/src/plugin-test/argfilemix.lst | 2 + aspectj/src/plugin-test/maven.xml | 12 +++++- .../aspect/org/apache/maven/aspectj/BOTest.aj | 29 ++++++++++++++ .../src/main/org/apache/maven/aspectj/BO.java | 38 +++++++++++++++++++ .../apache/maven/aspectj/AspectBOTest.java | 32 ++++++++++++++++ aspectj/xdocs/changes.xml | 1 + aspectj/xdocs/properties.xml | 10 +++++ 10 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 aspectj/src/plugin-test/argfilemix.lst create mode 100644 aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/BOTest.aj create mode 100644 aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/BO.java create mode 100644 aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectBOTest.java diff --git a/aspectj/plugin.jelly b/aspectj/plugin.jelly index 7be4cf99..f286ee73 100644 --- a/aspectj/plugin.jelly +++ b/aspectj/plugin.jelly @@ -88,10 +88,12 @@ - - - - + + + + + + diff --git a/aspectj/plugin.properties b/aspectj/plugin.properties index ef4740b3..cfe6eb48 100644 --- a/aspectj/plugin.properties +++ b/aspectj/plugin.properties @@ -24,6 +24,11 @@ # another argfile by reference. #maven.aspectj.argfiles= +# If true, only sources that are defined in argument files will be weaved. +# By default weave sources from argument files and from build sources path +# or test sources path. +#maven.aspectj.src.argfilesOnly=false + # If true weave aspect sources in pom.build.aspectSourceDirectory #maven.aspectj.weaveAspectSources=true diff --git a/aspectj/src/plugin-test/argfile.lst b/aspectj/src/plugin-test/argfile.lst index 6663747a..254ad785 100644 --- a/aspectj/src/plugin-test/argfile.lst +++ b/aspectj/src/plugin-test/argfile.lst @@ -1,2 +1,3 @@ src/aspect/org/apache/maven/aspectj/Sample.aj -src/aspect/org/apache/maven/aspectj/TestA.aj \ No newline at end of file +src/aspect/org/apache/maven/aspectj/TestA.aj +src/aspect/org/apache/maven/aspectj/BOTest.aj \ No newline at end of file diff --git a/aspectj/src/plugin-test/argfilemix.lst b/aspectj/src/plugin-test/argfilemix.lst new file mode 100644 index 00000000..47b6c04c --- /dev/null +++ b/aspectj/src/plugin-test/argfilemix.lst @@ -0,0 +1,2 @@ +src/aspect/org/apache/maven/aspectj/BOTest.aj +src/main/org/apache/maven/aspectj/BO.java \ No newline at end of file diff --git a/aspectj/src/plugin-test/maven.xml b/aspectj/src/plugin-test/maven.xml index d84466f6..d4795f17 100644 --- a/aspectj/src/plugin-test/maven.xml +++ b/aspectj/src/plugin-test/maven.xml @@ -17,7 +17,7 @@ --> - + @@ -32,4 +32,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/BOTest.aj b/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/BOTest.aj new file mode 100644 index 00000000..ed8fed5e --- /dev/null +++ b/aspectj/src/plugin-test/src/aspect/org/apache/maven/aspectj/BOTest.aj @@ -0,0 +1,29 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +public aspect BOTest +{ + pointcut mockupPointcut() : + execution(public * org.apache.maven.aspectj.BO.findByKey(..)); + + BO around() : mockupPointcut() + { + return new BO("dummy"); + } +} diff --git a/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/BO.java b/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/BO.java new file mode 100644 index 00000000..360c09fc --- /dev/null +++ b/aspectj/src/plugin-test/src/main/org/apache/maven/aspectj/BO.java @@ -0,0 +1,38 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +public class BO +{ + + private String id; + + public BO(String id){ + this.id = id; + } + + public static BO findByKey(String id) + { + //some code with connection to database + return null; + } + + public String getId(){ + return this.id; + } +} diff --git a/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectBOTest.java b/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectBOTest.java new file mode 100644 index 00000000..8534d054 --- /dev/null +++ b/aspectj/src/plugin-test/src/test/org/apache/maven/aspectj/AspectBOTest.java @@ -0,0 +1,32 @@ +package org.apache.maven.aspectj; + +/* ==================================================================== + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +import junit.framework.TestCase; + +public class AspectBOTest extends TestCase +{ + + public void testSourceIsCorrectlyWeaved() + { + BO bo = BO.findByKey("test"); + assertNotNull(bo); + assertEquals("dummy", bo.getId()); + + } + +} diff --git a/aspectj/xdocs/changes.xml b/aspectj/xdocs/changes.xml index f719f5b7..ada8c19d 100644 --- a/aspectj/xdocs/changes.xml +++ b/aspectj/xdocs/changes.xml @@ -28,6 +28,7 @@ + Unable to weave only sources defined in argument files. New property maven.aspectj.src.argfilesOnly. Add a report for the plugin. Upgraded to AspectJ 1.5.0 diff --git a/aspectj/xdocs/properties.xml b/aspectj/xdocs/properties.xml index eb1ba412..0f35e51e 100644 --- a/aspectj/xdocs/properties.xml +++ b/aspectj/xdocs/properties.xml @@ -61,6 +61,16 @@ + + maven.aspectj.src.argfilesOnly + Yes + + If true, only sources that are defined in argument files will be weaved. + By default, weave sources from argument files and from build- + or test sources path. + + + maven.aspectj.sourceRootCopyFilter Yes