MNG-5695 more custom guice scope tests

Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
Igor Fedorenko 2014-09-26 19:12:02 -04:00
parent c8c6565831
commit 08d65ae82b
17 changed files with 1028 additions and 1 deletions

View File

@ -74,7 +74,7 @@ public class MavenITmng5530MojoExecutionScopeTest
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.getCliOptions().add("--builder multithreaded -T 1");
verifier.getCliOptions().add( "--builder multithreaded -T 1" );
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
@ -84,4 +84,35 @@ public class MavenITmng5530MojoExecutionScopeTest
verifier.assertFilePresent( "target/execution-before.txt" );
}
public void testExtension()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5530-mojo-execution-scope" );
File extensionDir = new File( testDir, "extension" );
File pluginDir = new File( testDir, "extension-plugin" );
File projectDir = new File( testDir, "extension-project" );
Verifier verifier;
// install the test extension
verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// install the test plugin
verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.addCliOption( "-Dmaven.ext.class.path=" + new File( extensionDir, "target/classes" ).getAbsolutePath() );
verifier.setForkJvm( true ); // verifier does not support custom realms in embedded mode
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,135 @@
package org.apache.maven.it;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 java.io.File;
import org.apache.maven.it.util.ResourceExtractor;
public class MavenITmng5578SessionScopeTest
extends AbstractMavenIntegrationTestCase
{
public MavenITmng5578SessionScopeTest()
{
super( "[3.2.4,)" );
}
public void testBasic()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" );
File pluginDir = new File( testDir, "plugin" );
File projectDir = new File( testDir, "basic" );
Verifier verifier;
// install the test plugin
verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.addCliOption( "-Dit-build-extensions=false" );
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
}
public void testBasic_multithreaded()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" );
File pluginDir = new File( testDir, "plugin" );
File projectDir = new File( testDir, "basic" );
Verifier verifier;
// install the test plugin
verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.addCliOption( "-Dit-build-extensions=false" );
verifier.addCliOption( "--builder multithreaded -T 1" );
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
}
public void testBasic_buildExtension()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" );
File pluginDir = new File( testDir, "plugin" );
File projectDir = new File( testDir, "basic" );
Verifier verifier;
// install the test plugin
verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.addCliOption( "-Dit-build-extensions=true" );
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
}
public void testExtension()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" );
File extensionDir = new File( testDir, "extension" );
File pluginDir = new File( testDir, "extension-plugin" );
File projectDir = new File( testDir, "extension-project" );
Verifier verifier;
// install the test extension
verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// install the test plugin
verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" );
verifier.executeGoal( "install" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
// build the test project
verifier = newVerifier( projectDir.getAbsolutePath(), "remote" );
verifier.addCliOption( "-Dmaven.ext.class.path=" + new File( extensionDir, "target/classes" ).getAbsolutePath() );
verifier.setForkJvm( true ); // verifier does not support custom realms in embedded mode
verifier.executeGoal( "package" );
verifier.resetStreams();
verifier.verifyErrorFreeLog();
}
}

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5530-mojo-execution-scope</groupId>
<artifactId>mng-5530-mojo-execution-scope-extension-plugin</artifactId>
<version>0.1</version>
<packaging>maven-plugin</packaging>
<properties>
<maven-version>3.2.1</maven-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mng-5530-mojo-execution-scope</groupId>
<artifactId>mng-5530-mojo-execution-scope-extension</artifactId>
<version>0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,52 @@
package org.apache.maven.its.mng5530.sessionscope.plugin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.maven.its.mng5530.mojoexecutionscope.extension.TestMojoExecutionScopedComponent;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* @goal test-session-scope
*/
public class TestSessionScopeMojo
extends AbstractMojo
{
/** @component */
private TestMojoExecutionScopedComponent component;
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( component.session == null )
{
throw new NullPointerException();
}
if ( component.project == null )
{
throw new NullPointerException();
}
if ( component.execution == null )
{
throw new NullPointerException();
}
}
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5530-mojo-execution-scope</groupId>
<artifactId>mng-5530-mojo-execution-scope-extension-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>mng-5530-mojo-execution-scope</groupId>
<artifactId>mng-5530-mojo-execution-scope-extension-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>test-session-scope</id>
<goals>
<goal>test-session-scope</goal>
</goals>
<phase>process-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5530-mojo-execution-scope</groupId>
<artifactId>mng-5530-mojo-execution-scope-extension</artifactId>
<version>0.1</version>
<properties>
<maven-version>3.2.1</maven-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,37 @@
package org.apache.maven.its.mng5530.mojoexecutionscope.extension;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you 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 javax.inject.Named;
import org.apache.maven.classrealm.ClassRealmManagerDelegate;
import org.apache.maven.classrealm.ClassRealmRequest;
import org.apache.maven.classrealm.ClassRealmRequest.RealmType;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
@Named
public class TestClassRealmManagerDelegate
implements ClassRealmManagerDelegate
{
public void setupRealm( ClassRealm classRealm, ClassRealmRequest request )
{
if ( request.getType() == RealmType.Plugin )
{
request.getForeignImports().put( getClass().getPackage().getName() + ".*", getClass().getClassLoader() );
}
}
}

View File

@ -0,0 +1,44 @@
package org.apache.maven.its.mng5530.mojoexecutionscope.extension;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you 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 javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.scope.MojoExecutionScoped;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
@Named
@MojoExecutionScoped
public class TestMojoExecutionScopedComponent
{
public final MavenSession session;
public final MavenProject project;
public final MojoExecution execution;
@Inject
public TestMojoExecutionScopedComponent( MavenSession session, MavenProject project, MojoExecution execution )
{
this.session = session;
this.project = project;
this.execution = execution;
}
}

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-basic</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-plugin</artifactId>
<version>0.1</version>
<extensions>${it-build-extensions}</extensions>
<executions>
<execution>
<id>test-session-scope</id>
<goals>
<goal>test-session-scope</goal>
</goals>
<phase>process-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-extension-plugin</artifactId>
<version>0.1</version>
<packaging>maven-plugin</packaging>
<properties>
<maven-version>3.2.1</maven-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-extension</artifactId>
<version>0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,44 @@
package org.apache.maven.its.mng5530.sessionscope.plugin;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
/**
* @goal test-session-scope
*/
public class TestSessionScopeMojo
extends AbstractMojo
{
/** @parameter expression="${project}" */
private MavenProject project;
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( project.getContextValue( "TestSessionScopedComponent" ) == null )
{
throw new NullPointerException();
}
}
}

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-extension-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-extension-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>test-session-scope</id>
<goals>
<goal>test-session-scope</goal>
</goals>
<phase>process-resources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-extension</artifactId>
<version>0.1</version>
<properties>
<maven-version>3.2.1</maven-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,47 @@
package org.apache.maven.its.mng5578.sessionscope.extension;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you 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 javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.AbstractMavenLifecycleParticipant;
import org.apache.maven.MavenExecutionException;
import org.apache.maven.SessionScoped;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
@Named
@SessionScoped
public class TestSessionScopedComponent
extends AbstractMavenLifecycleParticipant
{
@Inject
public TestSessionScopedComponent( MavenSession session )
{
System.out.println();
}
@Override
public void afterProjectsRead( MavenSession session )
throws MavenExecutionException
{
for ( MavenProject project : session.getAllProjects() )
{
project.setContextValue( "TestSessionScopedComponent", "FTW" );
}
}
}

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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>mng-5578-session-scope</groupId>
<artifactId>mng-5578-session-scope-plugin</artifactId>
<version>0.1</version>
<packaging>maven-plugin</packaging>
<properties>
<maven-version>3.2.1</maven-version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<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>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>sisu-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>main-index</goal>
<goal>test-index</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,43 @@
package org.apache.maven.its.mng5530.sessionscope;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* @goal test-session-scope
*/
public class TestSessionScopeMojo
extends AbstractMojo
{
/** @component */
private TestSessionScopedComponent sessionScopedComponent;
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( sessionScopedComponent.getSession() == null )
{
throw new NullPointerException();
}
}
}

View File

@ -0,0 +1,45 @@
package org.apache.maven.its.mng5530.sessionscope;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 javax.inject.Inject;
import javax.inject.Named;
import org.apache.maven.SessionScoped;
import org.apache.maven.execution.MavenSession;
@Named
@SessionScoped
public class TestSessionScopedComponent
{
private MavenSession session;
@Inject
public TestSessionScopedComponent( MavenSession session )
{
this.session = session;
}
public MavenSession getSession()
{
return session;
}
}