Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 87b24ea

Browse files
author
Guillaume Boué
committed
[MANTRUN-179] Seems impossible to use combine.* attributes with maven-antrun-plugin configuration
During creation of the temporary Ant file, the Maven combine.children and combine.self attributes of the XML plugin configuration elements should be removed. Also refactoring the code generating the Ant build file, which is only the responsibility of the writer and not the Mojo, to use proper XML serialization instead of string manipulations. git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1799014 13f79535-47bb-0310-9956-ffa450edef68
1 parent ea5bd4d commit 87b24ea

19 files changed

Lines changed: 675 additions & 88 deletions

File tree

maven-antrun-plugin/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,34 @@ under the License.
9191
<artifactId>ant</artifactId>
9292
<version>1.9.4</version>
9393
</dependency>
94+
95+
<dependency>
96+
<groupId>junit</groupId>
97+
<artifactId>junit</artifactId>
98+
<version>4.11</version>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>xmlunit</groupId>
103+
<artifactId>xmlunit</artifactId>
104+
<version>1.6</version>
105+
<scope>test</scope>
106+
</dependency>
94107
</dependencies>
108+
109+
<build>
110+
<pluginManagement>
111+
<plugins>
112+
<plugin>
113+
<groupId>org.apache.rat</groupId>
114+
<artifactId>apache-rat-plugin</artifactId>
115+
<configuration>
116+
<excludes combine.children="append">
117+
<exclude>src/test/resources/configuration-writer/*.xml</exclude>
118+
</excludes>
119+
</configuration>
120+
</plugin>
121+
</plugins>
122+
</pluginManagement>
123+
</build>
95124
</project>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
25+
<modelVersion>4.0.0</modelVersion>
26+
<groupId>org.apache.maven.plugins.antrun</groupId>
27+
<artifactId>MANTRUN-179</artifactId>
28+
<packaging>pom</packaging>
29+
<version>1.0</version>
30+
<url>https://issues.apache.org/jira/browse/MANTRUN-179</url>
31+
<description>Checks that combine.* attributes in target do not interfere with Ant execution.</description>
32+
<build>
33+
<pluginManagement>
34+
<plugins>
35+
<plugin>
36+
<artifactId>maven-antrun-plugin</artifactId>
37+
<version>@pom.version@</version>
38+
<configuration>
39+
<target>
40+
<echo>From the pluginManagement</echo>
41+
</target>
42+
</configuration>
43+
</plugin>
44+
</plugins>
45+
</pluginManagement>
46+
<plugins>
47+
<plugin>
48+
<artifactId>maven-antrun-plugin</artifactId>
49+
<executions>
50+
<execution>
51+
<id>test</id>
52+
<goals>
53+
<goal>run</goal>
54+
</goals>
55+
<phase>validate</phase>
56+
<configuration>
57+
<target name="mytest" combine.children="append">
58+
<echo>From the exec config</echo>
59+
</target>
60+
</configuration>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
</project>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import java.io.File;
22+
23+
import org.codehaus.plexus.util.FileUtils;
24+
25+
try
26+
{
27+
File buildLog = new File( basedir, "build.log" );
28+
String log = FileUtils.fileRead( buildLog );
29+
30+
if ( !log.contains( "[echo] From the pluginManagement" ) ||
31+
!log.contains( "[echo] From the exec config" ) )
32+
{
33+
System.err.println( "Generated console output does not contain [echo] output: " + buildLog );
34+
return false;
35+
}
36+
}
37+
catch( Throwable t )
38+
{
39+
t.printStackTrace();
40+
return false;
41+
}
42+
43+
return true;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals = clean install
19+
invoker.buildResult = failure
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<groupId>org.apache.maven.plugins.antrun</groupId>
26+
<artifactId>attach-artifact-test-with-prefix-unknown</artifactId>
27+
<version>1.0</version>
28+
<packaging>pom</packaging>
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-antrun-plugin</artifactId>
33+
<version>@pom.version@</version>
34+
<executions>
35+
<execution>
36+
<id>call-build</id>
37+
<phase>compile</phase>
38+
<goals>
39+
<goal>run</goal>
40+
</goals>
41+
<configuration>
42+
<customTaskPrefix>mvn</customTaskPrefix>
43+
<target>
44+
<attachartifact file="test.txt" classifier="cl" />
45+
</target>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
invoker.goals=clean install
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<groupId>org.apache.maven.plugins.antrun</groupId>
26+
<artifactId>attach-artifact-test-with-prefix</artifactId>
27+
<version>1.0</version>
28+
<packaging>pom</packaging>
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<artifactId>maven-antrun-plugin</artifactId>
33+
<version>@pom.version@</version>
34+
<executions>
35+
<execution>
36+
<id>call-build</id>
37+
<phase>compile</phase>
38+
<goals>
39+
<goal>run</goal>
40+
</goals>
41+
<configuration>
42+
<customTaskPrefix>mvn</customTaskPrefix>
43+
<target>
44+
<mvn:attachartifact file="test.txt" classifier="cl" />
45+
</target>
46+
</configuration>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
/*
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
import java.io.*;
22+
23+
String[] expectedFiles = {
24+
"org/apache/maven/plugins/antrun/attach-artifact-test-with-prefix/1.0/attach-artifact-test-with-prefix-1.0.pom",
25+
"org/apache/maven/plugins/antrun/attach-artifact-test-with-prefix/1.0/attach-artifact-test-with-prefix-1.0-cl.txt"
26+
};
27+
28+
for ( String expectedFile : expectedFiles )
29+
{
30+
File file = new File( localRepositoryPath, expectedFile );
31+
System.out.println( "Checking for existence of " + file );
32+
if ( !file.isFile() )
33+
{
34+
throw new Exception( "Missing file " + file );
35+
}
36+
}

0 commit comments

Comments
 (0)