This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch maven-extention-demo
in repository https://gitbox.apache.org/repos/asf/maven-studies.git


The following commit(s) were added to refs/heads/maven-extention-demo by this 
push:
     new 34c297a  improved tests to work with Maven 3.0.x
34c297a is described below

commit 34c297a458e88cf80062429fc6b8fe2b8eaf64d9
Author: HervĂ© Boutemy <[email protected]>
AuthorDate: Thu Jul 26 22:05:50 2018 +0200

    improved tests to work with Maven 3.0.x
---
 src/it/-Dmaven.ext.class.path/invoker.properties   |  2 +-
 src/it/-Dmaven.ext.class.path/verify.groovy        | 27 +++++++++++++++++-----
 src/it/mvnExtensions/invoker.properties            |  2 +-
 src/it/mvnExtensions/verify.groovy                 | 27 +++++++++++++++++-----
 src/it/pomExtension/invoker.properties             |  2 +-
 src/it/pomExtension/verify.groovy                  | 27 +++++++++++++++++-----
 .../apache/maven/demo/extension/EventSpyDemo.java  | 11 ++++-----
 7 files changed, 71 insertions(+), 27 deletions(-)

diff --git a/src/it/-Dmaven.ext.class.path/invoker.properties 
b/src/it/-Dmaven.ext.class.path/invoker.properties
index 9063875..979a362 100755
--- a/src/it/-Dmaven.ext.class.path/invoker.properties
+++ b/src/it/-Dmaven.ext.class.path/invoker.properties
@@ -16,7 +16,7 @@
 # under the License.
 
 
invoker.mavenOpts=-Dmaven.ext.class.path=${project.basedir}/target/local-repo/org/apache/maven/demo/${project.artifactId}/${project.version}/${project.build.finalName}.jar
 
-invoker.goals=clean verify
+invoker.goals=-V clean verify
 
 # -Dmaven.ext.class.path feature added in Maven 3.0.2 with MNG-4936
 invoker.maven.version = 3.0.2+
diff --git a/src/it/-Dmaven.ext.class.path/verify.groovy 
b/src/it/-Dmaven.ext.class.path/verify.groovy
index 13be2d3..e5e263e 100644
--- a/src/it/-Dmaven.ext.class.path/verify.groovy
+++ b/src/it/-Dmaven.ext.class.path/verify.groovy
@@ -20,15 +20,30 @@ assert new File( basedir, 'build.log' ).exists();
 
 content = new File( basedir, 'build.log' ).text;
 
+boolean maven30 = content.contains( 'Apache Maven 3.0.' );
+boolean maven31 = content.contains( 'Apache Maven 3.1.' );
+
 assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionStart' );
 assert content.contains( 'LifecycleParticipantDemoPlexus afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+if ( maven30 || maven31 ) {
+  // afterSessionEnd API available only since Maven 3.2.1
+  assert !content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+} else { 
+  assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+}
 
-assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' );
-assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' );
+if ( maven30 ) {
+  assert !content.contains( 'LifecycleParticipantDemoJsr330 after' );
+} else {
+  assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' 
);
+  assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' 
);
+  if ( maven31 ) {
+    // afterSessionEnd API available only since Maven 3.2.1
+    assert !content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  } else { 
+    assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  }
+}
 
 assert content.contains( 'EventSpyDemo init:' );
 assert content.contains( 'EventSpyDemo close' );
diff --git a/src/it/mvnExtensions/invoker.properties 
b/src/it/mvnExtensions/invoker.properties
index 4cc1626..a34523f 100755
--- a/src/it/mvnExtensions/invoker.properties
+++ b/src/it/mvnExtensions/invoker.properties
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.goals=clean verify
+invoker.goals=-V clean verify
 
 # .mvn/extensions.xml feature added in Maven 3.3.1
 invoker.maven.version = 3.3.1+
diff --git a/src/it/mvnExtensions/verify.groovy 
b/src/it/mvnExtensions/verify.groovy
index 13be2d3..e5e263e 100644
--- a/src/it/mvnExtensions/verify.groovy
+++ b/src/it/mvnExtensions/verify.groovy
@@ -20,15 +20,30 @@ assert new File( basedir, 'build.log' ).exists();
 
 content = new File( basedir, 'build.log' ).text;
 
+boolean maven30 = content.contains( 'Apache Maven 3.0.' );
+boolean maven31 = content.contains( 'Apache Maven 3.1.' );
+
 assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionStart' );
 assert content.contains( 'LifecycleParticipantDemoPlexus afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+if ( maven30 || maven31 ) {
+  // afterSessionEnd API available only since Maven 3.2.1
+  assert !content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+} else { 
+  assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+}
 
-assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' );
-assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' );
+if ( maven30 ) {
+  assert !content.contains( 'LifecycleParticipantDemoJsr330 after' );
+} else {
+  assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' 
);
+  assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' 
);
+  if ( maven31 ) {
+    // afterSessionEnd API available only since Maven 3.2.1
+    assert !content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  } else { 
+    assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  }
+}
 
 assert content.contains( 'EventSpyDemo init:' );
 assert content.contains( 'EventSpyDemo close' );
diff --git a/src/it/pomExtension/invoker.properties 
b/src/it/pomExtension/invoker.properties
index d9a77de..3d686cd 100755
--- a/src/it/pomExtension/invoker.properties
+++ b/src/it/pomExtension/invoker.properties
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-invoker.goals=clean verify
+invoker.goals=-V clean verify
diff --git a/src/it/pomExtension/verify.groovy 
b/src/it/pomExtension/verify.groovy
index 1f3a97f..d4fcf4c 100644
--- a/src/it/pomExtension/verify.groovy
+++ b/src/it/pomExtension/verify.groovy
@@ -20,15 +20,30 @@ assert new File( basedir, 'build.log' ).exists();
 
 content = new File( basedir, 'build.log' ).text;
 
+boolean maven30 = content.contains( 'Apache Maven 3.0.' );
+boolean maven31 = content.contains( 'Apache Maven 3.1.' );
+
 assert !content.contains( 'LifecycleParticipantDemoPlexus afterSessionStart' 
); // not yet activated when POM extension
 assert content.contains( 'LifecycleParticipantDemoPlexus afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+if ( maven30 || maven31 ) {
+  // afterSessionEnd API available only since Maven 3.2.1
+  assert !content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+} else { 
+  assert content.contains( 'LifecycleParticipantDemoPlexus afterSessionEnd' );
+}
 
-assert !content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' 
); // not yet activated when POM extension
-assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' );
-// do not test since valid only since Maven 3.2.1: previous tests are 
sufficient
-//assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' );
+if ( maven30 ) {
+  assert !content.contains( 'LifecycleParticipantDemoJsr330 after' );
+} else {
+  assert !content.contains( 'LifecycleParticipantDemoJsr330 afterSessionStart' 
); // not yet activated when POM extension
+  assert content.contains( 'LifecycleParticipantDemoJsr330 afterProjectsRead' 
);
+  if ( maven31 ) {
+    // afterSessionEnd API available only since Maven 3.2.1
+    assert !content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  } else { 
+    assert content.contains( 'LifecycleParticipantDemoJsr330 afterSessionEnd' 
);
+  }
+}
 
 // EventSpy not activated when POM extension
 assert !content.contains( 'EventSpyDemo init:' );
diff --git a/src/main/java/org/apache/maven/demo/extension/EventSpyDemo.java 
b/src/main/java/org/apache/maven/demo/extension/EventSpyDemo.java
index 30cc589..0696639 100644
--- a/src/main/java/org/apache/maven/demo/extension/EventSpyDemo.java
+++ b/src/main/java/org/apache/maven/demo/extension/EventSpyDemo.java
@@ -22,21 +22,20 @@ package org.apache.maven.demo.extension;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.inject.Named;
-import javax.inject.Singleton;
-
 import org.apache.maven.eventspy.AbstractEventSpy;
+import org.apache.maven.eventspy.EventSpy;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.classworlds.ClassWorld;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.annotations.Component;
 
 /**
  * Event Spy demo (since Maven 3.0.2, with <a 
href="https://issues.apache.org/jira/browse/MNG-4936";>MNG-4936</a>).
  * <p>Notice: event spies are not activated from POM build extensions.
- * <p>Notice: JSR-330 annotations do not work on Maven 3.0.x, but only 
starting with 3.1
  */
-@Named( "demo" )
-@Singleton
+//@Named( "demo" )
+//@Singleton
+@Component( role = EventSpy.class, hint = "demo" ) // using Plexus Component 
annotations for Maven 3.0.x
 public class EventSpyDemo
     extends AbstractEventSpy
 {

Reply via email to