Author: bentmann Date: Mon Oct 6 10:55:00 2008 New Revision: 702214 URL: http://svn.apache.org/viewvc?rev=702214&view=rev Log: [MINVOKER-72] Allow to configure network mode for sub builds
Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml (with props) maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties (with props) maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml (with props) maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml (with props) Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/invoker-properties.apt.vm maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerPropertiesTest.java Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml?rev=702214&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml Mon Oct 6 10:55:00 2008 @@ -0,0 +1,66 @@ +<?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>org.apache.maven.plugins.invoker</groupId> + <artifactId>invocation-offline</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <description> + Test to check for usage of offline mode. + </description> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-invoker-plugin</artifactId> + <version>@pom.version@</version> + <configuration> + <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath> + <pomIncludes> + <pomInclude>*/pom.xml</pomInclude> + </pomIncludes> + <settingsFile>src/it/settings.xml</settingsFile> + <goals> + <goal>validate</goal> + </goals> + </configuration> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties?rev=702214&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties Mon Oct 6 10:55:00 2008 @@ -0,0 +1,7 @@ +# First run if offline mode which should fail to download the Clean Plugin +invoker.goals.1 = clean +invoker.offline.1 = true +invoker.buildResult.1 = failure + +# Now again in online mode +invoker.goals.2 = clean Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/invoker.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml?rev=702214&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml Mon Oct 6 10:55:00 2008 @@ -0,0 +1,41 @@ +<?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>test</groupId> + <artifactId>invocation-offline</artifactId> + <version>0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> +</project> Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/project/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml?rev=702214&view=auto ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml (added) +++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml Mon Oct 6 10:55:00 2008 @@ -0,0 +1,60 @@ +<?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. +--> + +<settings> + <profiles> + <profile> + <id>it-repo</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <!-- + NOTE: We don't use @localRepository@ here which refers to the isolated local repository of the ITs and is quite + empty. In contrast, @invoker.repo.local@ has been defined to refer to the original local repository which is a + far better source for artifacts. + --> + <repositories> + <repository> + <id>local.central</id> + <url>file://@invoker.repo.local@</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <pluginRepositories> + <pluginRepository> + <id>local.central</id> + <url>file://@invoker.repo.local@</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + </profile> + </profiles> +</settings> Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-offline/src/it/settings.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java?rev=702214&r1=702213&r2=702214&view=diff ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java (original) +++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerMojo.java Mon Oct 6 10:55:00 2008 @@ -439,8 +439,11 @@ * # The expected result of the build, possible values are "success" (default) and "failure" * invoker.buildResult=failure * - * # A boolean value controlling the -N flag, defaults to "false" - * invoker.nonRecursive=false + * # A boolean value controlling the aggregator mode of Maven, defaults to "false" + * invoker.nonRecursive=true + * + * # A boolean value controlling the network behavior of Maven, defaults to "false" + * invoker.offline=true * </pre> * * @parameter expression="${invoker.invokerPropertiesFile}" default-value="invoker.properties" @@ -1123,6 +1126,8 @@ request.setMavenOpts( mavenOpts ); + request.setOffline( false ); + invokerProperties.configureInvocation( request, invocationIndex ); try Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java?rev=702214&r1=702213&r2=702214&view=diff ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java (original) +++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InvokerProperties.java Mon Oct 6 10:55:00 2008 @@ -110,6 +110,12 @@ { request.setRecursive( !Boolean.valueOf( nonRecursive ).booleanValue() ); } + + String offline = get( "invoker.offline", index ); + if ( offline != null ) + { + request.setOffline( Boolean.valueOf( offline ).booleanValue() ); + } } /** Modified: maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/invoker-properties.apt.vm URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/invoker-properties.apt.vm?rev=702214&r1=702213&r2=702214&view=diff ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/invoker-properties.apt.vm (original) +++ maven/plugins/trunk/maven-invoker-plugin/src/site/apt/examples/invoker-properties.apt.vm Mon Oct 6 10:55:00 2008 @@ -67,8 +67,11 @@ # The expected result of the build, possible values are "success" (default) and "failure" invoker.buildResult=failure -# A boolean value controlling the -N flag, defaults to "false" -invoker.nonRecursive=false +# A boolean value controlling the aggregator mode of Maven, defaults to "false" +invoker.nonRecursive=true + +# A boolean value controlling the network behavior of Maven, defaults to "false" +invoker.offline=true +---- The comments given in the example should be rather self-explanatory. Looking closely, you can also notice that the Modified: maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerPropertiesTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerPropertiesTest.java?rev=702214&r1=702213&r2=702214&view=diff ============================================================================== --- maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerPropertiesTest.java (original) +++ maven/plugins/trunk/maven-invoker-plugin/src/test/java/org/apache/maven/plugin/invoker/InvokerPropertiesTest.java Mon Oct 6 10:55:00 2008 @@ -195,4 +195,28 @@ assertTrue( request.isRecursive() ); } + public void testConfigureRequestOffline() + throws Exception + { + Properties props = new Properties(); + InvokerProperties facade = new InvokerProperties( props ); + + InvocationRequest request = new DefaultInvocationRequest(); + + request.setOffline( true ); + facade.configureInvocation( request, 0 ); + assertTrue( request.isOffline() ); + request.setOffline( false ); + facade.configureInvocation( request, 0 ); + assertFalse( request.isOffline() ); + + props.setProperty( "invoker.offline", "true" ); + facade.configureInvocation( request, 0 ); + assertTrue( request.isOffline() ); + + props.setProperty( "invoker.offline", "false" ); + facade.configureInvocation( request, 0 ); + assertFalse( request.isOffline() ); + } + }