Repository: maven Updated Branches: refs/heads/master 406a46fd8 -> 2f7daeff5
[MNG-5871] refactoring: improved empty urls handling Project: http://git-wip-us.apache.org/repos/asf/maven/repo Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/2f7daeff Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/2f7daeff Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/2f7daeff Branch: refs/heads/master Commit: 2f7daeff5802174c7b4ff8a4d2ac019b6406d03b Parents: 406a46f Author: Hervé Boutemy <[email protected]> Authored: Sat Oct 31 12:55:47 2015 +0100 Committer: Hervé Boutemy <[email protected]> Committed: Sat Oct 31 12:55:47 2015 +0100 ---------------------------------------------------------------------- .../DefaultInheritanceAssembler.java | 5 ++- .../DefaultInheritanceAssemblerTest.java | 2 +- .../resources/poms/inheritance/empty-child.xml | 31 -------------- .../poms/inheritance/empty-expected.xml | 39 ----------------- .../resources/poms/inheritance/empty-parent.xml | 37 ---------------- .../poms/inheritance/empty-urls-child.xml | 31 ++++++++++++++ .../poms/inheritance/empty-urls-expected.xml | 44 ++++++++++++++++++++ .../poms/inheritance/empty-urls-parent.xml | 42 +++++++++++++++++++ 8 files changed, 121 insertions(+), 110 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java index fd1c07f..6cf4760 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/inheritance/DefaultInheritanceAssembler.java @@ -35,6 +35,7 @@ import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.model.building.ModelProblemCollector; import org.apache.maven.model.merge.MavenModelMerger; import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.StringUtils; /** * Handles inheritance of model values. @@ -136,7 +137,7 @@ public class DefaultInheritanceAssembler Object artifactId = context.get( ARTIFACT_ID ); Object childPathAdjustment = context.get( CHILD_PATH_ADJUSTMENT ); - if ( artifactId != null && childPathAdjustment != null ) + if ( artifactId != null && childPathAdjustment != null && StringUtils.isNotBlank( parentUrl ) ) { // append childPathAdjustment and artifactId to parent url return appendPath( parentUrl, artifactId.toString(), childPathAdjustment.toString() ); @@ -161,7 +162,7 @@ public class DefaultInheritanceAssembler private void concatPath( StringBuilder url, String path ) { - if ( url.length() > 0 && path.length() > 0 ) + if ( path.length() > 0 ) { boolean initialUrlEndsWithSlash = url.charAt( url.length() - 1 ) == '/'; boolean pathStartsWithSlash = path.charAt( 0 ) == '/'; http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java index 60f860f..e477fde 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java @@ -140,7 +140,7 @@ public class DefaultInheritanceAssemblerTest public void testWithEmptyUrl() throws Exception { - testInheritance( "empty", false ); + testInheritance( "empty-urls", false ); } public void testInheritance( String baseName ) http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml deleted file mode 100644 index 88ccde4..0000000 --- a/maven-model-builder/src/test/resources/poms/inheritance/empty-child.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>inheritance</groupId> - <artifactId>empty</artifactId> - <version>1</version> - </parent> - <artifactId>child</artifactId> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml deleted file mode 100644 index eac914a..0000000 --- a/maven-model-builder/src/test/resources/poms/inheritance/empty-expected.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>inheritance</groupId> - <artifactId>empty</artifactId> - <version>1</version> - </parent> - <groupId>inheritance</groupId> - <artifactId>child</artifactId> - <version>1</version> - <url></url> - <scm> - <connection>scm:my-scm:http://domain.org/base/child</connection> - <developerConnection>scm:my-scm:https://domain.org/base/child/</developerConnection> - <url></url> - </scm> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml deleted file mode 100644 index 8e94403..0000000 --- a/maven-model-builder/src/test/resources/poms/inheritance/empty-parent.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?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/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>inheritance</groupId> - <artifactId>empty</artifactId> - <version>1</version> - <modules> - <module>child</module> - </modules> - <url></url> - <scm> - <connection>scm:my-scm:http://domain.org/base</connection> - <developerConnection>scm:my-scm:https://domain.org/base/</developerConnection> - <url></url> - </scm> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-child.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-child.xml new file mode 100644 index 0000000..88ccde4 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-child.xml @@ -0,0 +1,31 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>inheritance</groupId> + <artifactId>empty</artifactId> + <version>1</version> + </parent> + <artifactId>child</artifactId> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-expected.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-expected.xml new file mode 100644 index 0000000..317aec8 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-expected.xml @@ -0,0 +1,44 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>inheritance</groupId> + <artifactId>empty</artifactId> + <version>1</version> + </parent> + <groupId>inheritance</groupId> + <artifactId>child</artifactId> + <version>1</version> + <url></url> + <scm> + <connection></connection> + <developerConnection></developerConnection> + <url></url> + </scm> + <distributionManagement> + <site> + <url></url> + </site> + </distributionManagement> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/maven/blob/2f7daeff/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-parent.xml ---------------------------------------------------------------------- diff --git a/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-parent.xml new file mode 100644 index 0000000..ab2bea7 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/empty-urls-parent.xml @@ -0,0 +1,42 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>inheritance</groupId> + <artifactId>empty</artifactId> + <version>1</version> + <modules> + <module>child</module> + </modules> + <url></url> + <scm> + <connection> </connection> + <developerConnection> </developerConnection> + <url></url> + </scm> + <distributionManagement> + <site> + <url></url> + </site> + </distributionManagement> +</project> \ No newline at end of file
