diff --git a/deploySite.bat b/deploySite.bat index 4d6dcb7f7..e1cc989fd 100644 --- a/deploySite.bat +++ b/deploySite.bat @@ -1,21 +1,21 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -mvn -Preporting site site:stage %* -mvn scm-publish:publish-scm %* +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +mvn -Preporting site site:stage %* +mvn scm-publish:publish-scm %* diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/PolicyException.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/PolicyException.java index 2c0f161cd..a3d7c340a 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/PolicyException.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/PolicyException.java @@ -1,39 +1,39 @@ -package org.apache.maven.shared.release.policy; - -/* - * 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. - */ - -/** - * - * @since 2.5.1 (MRELEASE-431) - */ -public class PolicyException - extends Exception -{ - - public PolicyException( String message ) - { - super( message ); - } - - public PolicyException( String message, Exception exception ) - { - super( message, exception ); - } -} +package org.apache.maven.shared.release.policy; + +/* + * 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. + */ + +/** + * + * @since 2.5.1 (MRELEASE-431) + */ +public class PolicyException + extends Exception +{ + + public PolicyException( String message ) + { + super( message ); + } + + public PolicyException( String message, Exception exception ) + { + super( message, exception ); + } +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicy.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicy.java index 2257df390..467f2cd82 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicy.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicy.java @@ -1,41 +1,41 @@ -package org.apache.maven.shared.release.policy.naming; - -/* - * 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.shared.release.policy.PolicyException; - -/** - * API for branch and tag naming. Used by maven-release-plugin to suggest names for tags and branches. - * - * @since 3.0.0 (MRELEASE-979) - */ -public interface NamingPolicy -{ - /** - * @return the calculation of the name used for branching or tagging. - * - * @param request the {@code NamingPolicyRequest} - * - * @throws PolicyException if exception in the policy - */ - NamingPolicyResult getName( NamingPolicyRequest request ) - throws PolicyException; - -} +package org.apache.maven.shared.release.policy.naming; + +/* + * 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.shared.release.policy.PolicyException; + +/** + * API for branch and tag naming. Used by maven-release-plugin to suggest names for tags and branches. + * + * @since 3.0.0 (MRELEASE-979) + */ +public interface NamingPolicy +{ + /** + * @return the calculation of the name used for branching or tagging. + * + * @param request the {@code NamingPolicyRequest} + * + * @throws PolicyException if exception in the policy + */ + NamingPolicyResult getName( NamingPolicyRequest request ) + throws PolicyException; + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyRequest.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyRequest.java index 7b59986a1..d6181425a 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyRequest.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyRequest.java @@ -1,67 +1,67 @@ -package org.apache.maven.shared.release.policy.naming; - -/* - * 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. - */ - -/** - * - * @author Robert Scholte - * @since 3.0.0 - */ -public class NamingPolicyRequest -{ - private String groupId; - - private String artifactId; - - private String version; - - public String getGroupId() - { - return groupId; - } - - public NamingPolicyRequest setGroupId( String groupId ) - { - this.groupId = groupId; - return this; - } - - public String getArtifactId() - { - return artifactId; - } - - public NamingPolicyRequest setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - return this; - } - - public String getVersion() - { - return version; - } - - public NamingPolicyRequest setVersion( String version ) - { - this.version = version; - return this; - } -} +package org.apache.maven.shared.release.policy.naming; + +/* + * 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. + */ + +/** + * + * @author Robert Scholte + * @since 3.0.0 + */ +public class NamingPolicyRequest +{ + private String groupId; + + private String artifactId; + + private String version; + + public String getGroupId() + { + return groupId; + } + + public NamingPolicyRequest setGroupId( String groupId ) + { + this.groupId = groupId; + return this; + } + + public String getArtifactId() + { + return artifactId; + } + + public NamingPolicyRequest setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + return this; + } + + public String getVersion() + { + return version; + } + + public NamingPolicyRequest setVersion( String version ) + { + this.version = version; + return this; + } +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyResult.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyResult.java index 8e48d3f09..411e8b724 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyResult.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/naming/NamingPolicyResult.java @@ -1,44 +1,44 @@ -package org.apache.maven.shared.release.policy.naming; - -/* - * 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. - */ - -/** - * - * @since 3.0.0 (MRELEASE-979) - */ -public class NamingPolicyResult -{ - /** - * The tag or branch name to use. - */ - private String name; - - public String getName() - { - return name; - } - - public NamingPolicyResult setName( String name ) - { - this.name = name; - return this; - } - -} +package org.apache.maven.shared.release.policy.naming; + +/* + * 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. + */ + +/** + * + * @since 3.0.0 (MRELEASE-979) + */ +public class NamingPolicyResult +{ + /** + * The tag or branch name to use. + */ + private String name; + + public String getName() + { + return name; + } + + public NamingPolicyResult setName( String name ) + { + this.name = name; + return this; + } + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicy.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicy.java index 55bffae7f..607080247 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicy.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicy.java @@ -1,53 +1,53 @@ -package org.apache.maven.shared.release.policy.version; - -/* - * 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.shared.release.policy.PolicyException; -import org.apache.maven.shared.release.versions.VersionParseException; - -/** - * API for next version calculations, used by maven-release-plugin to suggest release and next develoment versions. - * - * @since 2.5.1 (MRELEASE-431) - */ -public interface VersionPolicy -{ - /** - * @return the calculation of the release version from development state. - * - * @param request the {@code VersionPolicyRequest} - * - * @throws PolicyException if exception in the policy - * @throws VersionParseException if exception parsing the version - */ - VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException; - - /** - * @return the calculation of the next development version from release state. - * - * @param request the {@code VersionPolicyRequest} - * - * @throws PolicyException if exception in the policy - * @throws VersionParseException if exception parsing the version - */ - VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException; -} +package org.apache.maven.shared.release.policy.version; + +/* + * 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.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.versions.VersionParseException; + +/** + * API for next version calculations, used by maven-release-plugin to suggest release and next develoment versions. + * + * @since 2.5.1 (MRELEASE-431) + */ +public interface VersionPolicy +{ + /** + * @return the calculation of the release version from development state. + * + * @param request the {@code VersionPolicyRequest} + * + * @throws PolicyException if exception in the policy + * @throws VersionParseException if exception parsing the version + */ + VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException; + + /** + * @return the calculation of the next development version from release state. + * + * @param request the {@code VersionPolicyRequest} + * + * @throws PolicyException if exception in the policy + * @throws VersionParseException if exception parsing the version + */ + VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException; +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyRequest.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyRequest.java index 749aa7ab3..36bd1a148 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyRequest.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyRequest.java @@ -1,57 +1,57 @@ -package org.apache.maven.shared.release.policy.version; - -/* - * 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.artifact.repository.metadata.Metadata; - -/** - * - * @since 2.5.1 (MRELEASE-431) - */ -public class VersionPolicyRequest -{ - - private String version; - - private Metadata metaData; - - public String getVersion() - { - return version; - } - - public VersionPolicyRequest setVersion( String version ) - { - this.version = version; - return this; - } - - public Metadata getMetaData() - { - return metaData; - } - - public VersionPolicyRequest setMetaData( Metadata metaData ) - { - this.metaData = metaData; - return this; - } - -} +package org.apache.maven.shared.release.policy.version; + +/* + * 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.artifact.repository.metadata.Metadata; + +/** + * + * @since 2.5.1 (MRELEASE-431) + */ +public class VersionPolicyRequest +{ + + private String version; + + private Metadata metaData; + + public String getVersion() + { + return version; + } + + public VersionPolicyRequest setVersion( String version ) + { + this.version = version; + return this; + } + + public Metadata getMetaData() + { + return metaData; + } + + public VersionPolicyRequest setMetaData( Metadata metaData ) + { + this.metaData = metaData; + return this; + } + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyResult.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyResult.java index a6d0d51f6..de7fb5836 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyResult.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/policy/version/VersionPolicyResult.java @@ -1,41 +1,41 @@ -package org.apache.maven.shared.release.policy.version; - -/* - * 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. - */ - -/** - * - * @since 2.5.1 (MRELEASE-431) - */ -public class VersionPolicyResult -{ - private String version; - - public String getVersion() - { - return version; - } - - public VersionPolicyResult setVersion( String version ) - { - this.version = version; - return this; - } - -} +package org.apache.maven.shared.release.policy.version; + +/* + * 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. + */ + +/** + * + * @since 2.5.1 (MRELEASE-431) + */ +public class VersionPolicyResult +{ + private String version; + + public String getVersion() + { + return version; + } + + public VersionPolicyResult setVersion( String version ) + { + this.version = version; + return this; + } + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/AetherVersion.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/AetherVersion.java index 58139fbc9..55a014c4b 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/AetherVersion.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/AetherVersion.java @@ -1,53 +1,53 @@ -package org.apache.maven.shared.release.versions; - -/* - * 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.eclipse.aether.util.version.GenericVersionScheme; -import org.eclipse.aether.version.InvalidVersionSpecificationException; - -class AetherVersion - implements org.eclipse.aether.version.Version -{ - private final org.eclipse.aether.version.Version version; - - AetherVersion( String version ) - throws VersionParseException - { - try - { - this.version = new GenericVersionScheme().parseVersion( version ); - } - catch ( InvalidVersionSpecificationException e ) - { - throw new VersionParseException( e.getMessage() ); - } - } - - @Override - public String toString() - { - return this.version.toString(); - } - - public int compareTo( org.eclipse.aether.version.Version other ) - { - return this.version.compareTo( other ); - } -} +package org.apache.maven.shared.release.versions; + +/* + * 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.eclipse.aether.util.version.GenericVersionScheme; +import org.eclipse.aether.version.InvalidVersionSpecificationException; + +class AetherVersion + implements org.eclipse.aether.version.Version +{ + private final org.eclipse.aether.version.Version version; + + AetherVersion( String version ) + throws VersionParseException + { + try + { + this.version = new GenericVersionScheme().parseVersion( version ); + } + catch ( InvalidVersionSpecificationException e ) + { + throw new VersionParseException( e.getMessage() ); + } + } + + @Override + public String toString() + { + return this.version.toString(); + } + + public int compareTo( org.eclipse.aether.version.Version other ) + { + return this.version.compareTo( other ); + } +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/MavenArtifactVersion.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/MavenArtifactVersion.java index 1c379fba5..25a2acb17 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/MavenArtifactVersion.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/MavenArtifactVersion.java @@ -1,109 +1,109 @@ -package org.apache.maven.shared.release.versions; - -/* - * 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.artifact.versioning.ArtifactVersion; -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; - -class MavenArtifactVersion - implements ArtifactVersion -{ - private final ArtifactVersion version; - - MavenArtifactVersion( String version ) - { - this.version = new DefaultArtifactVersion( version ); - } - - public int compareTo( Object o ) - { - if ( o instanceof MavenArtifactVersion ) - { - return version.compareTo( ( (MavenArtifactVersion) o ).version ); - } - else - { - return version.compareTo( version ); - } - } - - public int getMajorVersion() - { - return version.getMajorVersion(); - } - - public int getMinorVersion() - { - return version.getMinorVersion(); - } - - public int getIncrementalVersion() - { - return version.getIncrementalVersion(); - } - - public int getBuildNumber() - { - return version.getBuildNumber(); - } - - public String getQualifier() - { - return version.getQualifier(); - } - - public void parseVersion( String version ) - { - this.version.parseVersion( version ); - } - - @Override - public String toString() - { - return this.version.toString(); - } - - @Override - public int hashCode() - { - return this.version.hashCode(); - } - - @Override - public boolean equals( Object other ) - { - if ( this == other ) - { - return true; - } - if ( other == null ) - { - return false; - } - - if ( other instanceof MavenArtifactVersion ) - { - return version.equals( ( (MavenArtifactVersion) other ).version ); - } - return false; - } - - -} +package org.apache.maven.shared.release.versions; + +/* + * 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.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; + +class MavenArtifactVersion + implements ArtifactVersion +{ + private final ArtifactVersion version; + + MavenArtifactVersion( String version ) + { + this.version = new DefaultArtifactVersion( version ); + } + + public int compareTo( Object o ) + { + if ( o instanceof MavenArtifactVersion ) + { + return version.compareTo( ( (MavenArtifactVersion) o ).version ); + } + else + { + return version.compareTo( version ); + } + } + + public int getMajorVersion() + { + return version.getMajorVersion(); + } + + public int getMinorVersion() + { + return version.getMinorVersion(); + } + + public int getIncrementalVersion() + { + return version.getIncrementalVersion(); + } + + public int getBuildNumber() + { + return version.getBuildNumber(); + } + + public String getQualifier() + { + return version.getQualifier(); + } + + public void parseVersion( String version ) + { + this.version.parseVersion( version ); + } + + @Override + public String toString() + { + return this.version.toString(); + } + + @Override + public int hashCode() + { + return this.version.hashCode(); + } + + @Override + public boolean equals( Object other ) + { + if ( this == other ) + { + return true; + } + if ( other == null ) + { + return false; + } + + if ( other instanceof MavenArtifactVersion ) + { + return version.equals( ( (MavenArtifactVersion) other ).version ); + } + return false; + } + + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java index 2fdf1c1ed..7d4fbcded 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java @@ -1,337 +1,337 @@ -package org.apache.maven.shared.release.versions; - -/* - * 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.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.maven.artifact.ArtifactUtils; -import org.codehaus.plexus.util.StringUtils; - -/** - * - */ -public class Version - implements Comparable, Cloneable -{ - private final AetherVersion aetherVersion; - - private final MavenArtifactVersion mavenArtifactVersion; - - private final String strVersion; - - private final List digits; - - private String annotation; - - private String annotationRevision; - - private final String buildSpecifier; - - private String annotationSeparator; - - private String annotationRevSeparator; - - private String buildSeparator; - - private static final int DIGITS_INDEX = 1; - - private static final int ANNOTATION_SEPARATOR_INDEX = 2; - - private static final int ANNOTATION_INDEX = 3; - - private static final int ANNOTATION_REV_SEPARATOR_INDEX = 4; - - private static final int ANNOTATION_REVISION_INDEX = 5; - - private static final int BUILD_SEPARATOR_INDEX = 6; - - private static final int BUILD_SPECIFIER_INDEX = 7; - - private static final String SNAPSHOT_IDENTIFIER = "SNAPSHOT"; - - private static final String DIGIT_SEPARATOR_STRING = "."; - - private static final String DEFAULT_ANNOTATION_REV_SEPARATOR = "-"; - - private static final String DEFAULT_BUILD_SEPARATOR = "-"; - - public static final Pattern STANDARD_PATTERN = Pattern.compile( "^((?:\\d+\\.)*\\d+)" // digit(s) and '.' repeated - - // followed by digit (version - // digits 1.22.0, etc) - + "([-_])?" // optional - or _ (annotation separator) - + "([a-zA-Z]*)" // alpha characters (looking for annotation - alpha, beta, RC, etc.) - + "([-_])?" // optional - or _ (annotation revision separator) - + "(\\d*)" // digits (any digits after rc or beta is an annotation revision) - + "(?:([-_])?(.*?))?$" ); // - or _ followed everything else (build specifier) - - /* * - * cmaki 02242009 FIX for non-digit release numbers, e.g. trunk-SNAPSHOT or just SNAPSHOT This alternate pattern - * supports version numbers like: trunk-SNAPSHOT branchName-SNAPSHOT SNAPSHOT - */ - // for SNAPSHOT releases only (possible versions include: trunk-SNAPSHOT or SNAPSHOT) - public static final Pattern ALTERNATE_PATTERN = Pattern.compile( "^(SNAPSHOT|[a-zA-Z]+[_-]SNAPSHOT)" ); - - private Version( List digits, String annotation, String annotationRevision, String buildSpecifier, - String annotationSeparator, String annotationRevSeparator, String buildSeparator ) - { - this.digits = digits; - this.annotation = annotation; - this.annotationRevision = annotationRevision; - this.buildSpecifier = buildSpecifier; - this.annotationSeparator = annotationSeparator; - this.annotationRevSeparator = annotationRevSeparator; - this.buildSeparator = buildSeparator; - this.strVersion = getVersionString( this, buildSpecifier, buildSeparator ); - - // for now no need to reparse, original version was valid - this.aetherVersion = null; - this.mavenArtifactVersion = null; - } - - public Version( String version ) - throws VersionParseException - { - this.strVersion = version; - this.aetherVersion = new AetherVersion( version ); - this.mavenArtifactVersion = new MavenArtifactVersion( version ); - - // FIX for non-digit release numbers, e.g. trunk-SNAPSHOT or just SNAPSHOT - Matcher matcher = ALTERNATE_PATTERN.matcher( strVersion ); - // TODO: hack because it didn't support "SNAPSHOT" - if ( matcher.matches() ) - { - annotation = null; - digits = null; - buildSpecifier = version; - buildSeparator = null; - return; - } - - Matcher m = STANDARD_PATTERN.matcher( strVersion ); - if ( m.matches() ) - { - digits = parseDigits( m.group( DIGITS_INDEX ) ); - if ( !SNAPSHOT_IDENTIFIER.equals( m.group( ANNOTATION_INDEX ) ) ) - { - annotationSeparator = m.group( ANNOTATION_SEPARATOR_INDEX ); - annotation = nullIfEmpty( m.group( ANNOTATION_INDEX ) ); - - if ( StringUtils.isNotEmpty( m.group( ANNOTATION_REV_SEPARATOR_INDEX ) ) - && StringUtils.isEmpty( m.group( ANNOTATION_REVISION_INDEX ) ) ) - { - // The build separator was picked up as the annotation revision separator - buildSeparator = m.group( ANNOTATION_REV_SEPARATOR_INDEX ); - buildSpecifier = nullIfEmpty( m.group( BUILD_SPECIFIER_INDEX ) ); - } - else - { - annotationRevSeparator = m.group( ANNOTATION_REV_SEPARATOR_INDEX ); - annotationRevision = nullIfEmpty( m.group( ANNOTATION_REVISION_INDEX ) ); - - buildSeparator = m.group( BUILD_SEPARATOR_INDEX ); - buildSpecifier = nullIfEmpty( m.group( BUILD_SPECIFIER_INDEX ) ); - } - } - else - { - // Annotation was "SNAPSHOT" so populate the build specifier with that data - buildSeparator = m.group( ANNOTATION_SEPARATOR_INDEX ); - buildSpecifier = nullIfEmpty( m.group( ANNOTATION_INDEX ) ); - } - } - else - { - throw new VersionParseException( "Unable to parse the version string: \"" + version + "\"" ); - } - } - - public boolean isSnapshot() - { - return ArtifactUtils.isSnapshot( strVersion ); - } - - public String toString() - { - return strVersion; - } - - protected static String getVersionString( Version info, String buildSpecifier, String buildSeparator ) - { - StringBuilder sb = new StringBuilder(); - - if ( info.digits != null ) - { - sb.append( joinDigitString( info.digits ) ); - } - - if ( StringUtils.isNotEmpty( info.annotation ) ) - { - sb.append( StringUtils.defaultString( info.annotationSeparator ) ); - sb.append( info.annotation ); - } - - if ( StringUtils.isNotEmpty( info.annotationRevision ) ) - { - if ( StringUtils.isEmpty( info.annotation ) ) - { - sb.append( StringUtils.defaultString( info.annotationSeparator ) ); - } - else - { - sb.append( StringUtils.defaultString( info.annotationRevSeparator ) ); - } - sb.append( info.annotationRevision ); - } - - if ( StringUtils.isNotEmpty( buildSpecifier ) ) - { - sb.append( StringUtils.defaultString( buildSeparator ) ); - sb.append( buildSpecifier ); - } - - return sb.toString(); - } - - /** - * Simply joins the items in the list with "." period - * - * @return a {@code String} containing the items in the list joined by "." period - * @param digits the list of digits {@code List} - */ - protected static String joinDigitString( List digits ) - { - return digits != null ? StringUtils.join( digits.iterator(), DIGIT_SEPARATOR_STRING ) : null; - } - - /** - * Splits the string on "." and returns a list containing each digit. - * - * @param strDigits - */ - private List parseDigits( String strDigits ) - { - return Arrays.asList( StringUtils.split( strDigits, DIGIT_SEPARATOR_STRING ) ); - } - - private static String nullIfEmpty( String s ) - { - return StringUtils.isEmpty( s ) ? null : s; - } - - public List getDigits() - { - return digits; - } - - public String getAnnotation() - { - return annotation; - } - - public String getAnnotationRevSeparator() - { - return annotationRevSeparator; - } - - public String getAnnotationRevision() - { - return annotationRevision; - } - - public String getBuildSeparator() - { - return buildSeparator; - } - - public String getBuildSpecifier() - { - return buildSpecifier; - } - - /** - * - * @param newDigits the new list of digits - * @return a new instance of Version - */ - public Version setDigits( List newDigits ) - { - return new Version( newDigits, this.annotation, this.annotationRevision, this.buildSpecifier, - this.annotationSeparator, this.annotationRevSeparator, this.buildSeparator ); - } - - /** - * - * @param newAnnotationRevision the new annotation revision - * @return a new instance of Version - */ - public Version setAnnotationRevision( String newAnnotationRevision ) - { - return new Version( this.digits, this.annotation, newAnnotationRevision, this.buildSpecifier, - this.annotationSeparator, - Objects.toString( this.annotationRevSeparator, DEFAULT_ANNOTATION_REV_SEPARATOR ), - this.buildSeparator ); - } - - /** - * - * @param newBuildSpecifier the new build specifier - * @return a new instance of Version - */ - public Version setBuildSpecifier( String newBuildSpecifier ) - { - return new Version( this.digits, this.annotation, this.annotationRevision, newBuildSpecifier, - this.annotationSeparator, this.annotationRevSeparator, - Objects.toString( this.buildSeparator, DEFAULT_BUILD_SEPARATOR ) ); - } - - /** - * @throws VersionComparisonConflictException if {@link org.eclipse.aether.version.Version} and - * {@link org.apache.maven.artifact.versioning.ArtifactVersion ArtifactVersion} give different results - */ - public int compareTo( Version other ) - throws VersionComparisonConflictException - { - int aetherComparisonResult = this.aetherVersion.compareTo( other.aetherVersion ); - int mavenComparisonResult = this.mavenArtifactVersion.compareTo( other.mavenArtifactVersion ); - - if ( aetherComparisonResult < 0 && mavenComparisonResult < 0 ) - { - return -1; - } - else if ( aetherComparisonResult == 0 && mavenComparisonResult == 0 ) - { - return 0; - } - else if ( aetherComparisonResult > 0 && mavenComparisonResult > 0 ) - { - return 1; - } - else - { - throw new VersionComparisonConflictException( this.strVersion, other.strVersion, aetherComparisonResult, - mavenComparisonResult ); - } - } - -} +package org.apache.maven.shared.release.versions; + +/* + * 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.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.artifact.ArtifactUtils; +import org.codehaus.plexus.util.StringUtils; + +/** + * + */ +public class Version + implements Comparable, Cloneable +{ + private final AetherVersion aetherVersion; + + private final MavenArtifactVersion mavenArtifactVersion; + + private final String strVersion; + + private final List digits; + + private String annotation; + + private String annotationRevision; + + private final String buildSpecifier; + + private String annotationSeparator; + + private String annotationRevSeparator; + + private String buildSeparator; + + private static final int DIGITS_INDEX = 1; + + private static final int ANNOTATION_SEPARATOR_INDEX = 2; + + private static final int ANNOTATION_INDEX = 3; + + private static final int ANNOTATION_REV_SEPARATOR_INDEX = 4; + + private static final int ANNOTATION_REVISION_INDEX = 5; + + private static final int BUILD_SEPARATOR_INDEX = 6; + + private static final int BUILD_SPECIFIER_INDEX = 7; + + private static final String SNAPSHOT_IDENTIFIER = "SNAPSHOT"; + + private static final String DIGIT_SEPARATOR_STRING = "."; + + private static final String DEFAULT_ANNOTATION_REV_SEPARATOR = "-"; + + private static final String DEFAULT_BUILD_SEPARATOR = "-"; + + public static final Pattern STANDARD_PATTERN = Pattern.compile( "^((?:\\d+\\.)*\\d+)" // digit(s) and '.' repeated - + // followed by digit (version + // digits 1.22.0, etc) + + "([-_])?" // optional - or _ (annotation separator) + + "([a-zA-Z]*)" // alpha characters (looking for annotation - alpha, beta, RC, etc.) + + "([-_])?" // optional - or _ (annotation revision separator) + + "(\\d*)" // digits (any digits after rc or beta is an annotation revision) + + "(?:([-_])?(.*?))?$" ); // - or _ followed everything else (build specifier) + + /* * + * cmaki 02242009 FIX for non-digit release numbers, e.g. trunk-SNAPSHOT or just SNAPSHOT This alternate pattern + * supports version numbers like: trunk-SNAPSHOT branchName-SNAPSHOT SNAPSHOT + */ + // for SNAPSHOT releases only (possible versions include: trunk-SNAPSHOT or SNAPSHOT) + public static final Pattern ALTERNATE_PATTERN = Pattern.compile( "^(SNAPSHOT|[a-zA-Z]+[_-]SNAPSHOT)" ); + + private Version( List digits, String annotation, String annotationRevision, String buildSpecifier, + String annotationSeparator, String annotationRevSeparator, String buildSeparator ) + { + this.digits = digits; + this.annotation = annotation; + this.annotationRevision = annotationRevision; + this.buildSpecifier = buildSpecifier; + this.annotationSeparator = annotationSeparator; + this.annotationRevSeparator = annotationRevSeparator; + this.buildSeparator = buildSeparator; + this.strVersion = getVersionString( this, buildSpecifier, buildSeparator ); + + // for now no need to reparse, original version was valid + this.aetherVersion = null; + this.mavenArtifactVersion = null; + } + + public Version( String version ) + throws VersionParseException + { + this.strVersion = version; + this.aetherVersion = new AetherVersion( version ); + this.mavenArtifactVersion = new MavenArtifactVersion( version ); + + // FIX for non-digit release numbers, e.g. trunk-SNAPSHOT or just SNAPSHOT + Matcher matcher = ALTERNATE_PATTERN.matcher( strVersion ); + // TODO: hack because it didn't support "SNAPSHOT" + if ( matcher.matches() ) + { + annotation = null; + digits = null; + buildSpecifier = version; + buildSeparator = null; + return; + } + + Matcher m = STANDARD_PATTERN.matcher( strVersion ); + if ( m.matches() ) + { + digits = parseDigits( m.group( DIGITS_INDEX ) ); + if ( !SNAPSHOT_IDENTIFIER.equals( m.group( ANNOTATION_INDEX ) ) ) + { + annotationSeparator = m.group( ANNOTATION_SEPARATOR_INDEX ); + annotation = nullIfEmpty( m.group( ANNOTATION_INDEX ) ); + + if ( StringUtils.isNotEmpty( m.group( ANNOTATION_REV_SEPARATOR_INDEX ) ) + && StringUtils.isEmpty( m.group( ANNOTATION_REVISION_INDEX ) ) ) + { + // The build separator was picked up as the annotation revision separator + buildSeparator = m.group( ANNOTATION_REV_SEPARATOR_INDEX ); + buildSpecifier = nullIfEmpty( m.group( BUILD_SPECIFIER_INDEX ) ); + } + else + { + annotationRevSeparator = m.group( ANNOTATION_REV_SEPARATOR_INDEX ); + annotationRevision = nullIfEmpty( m.group( ANNOTATION_REVISION_INDEX ) ); + + buildSeparator = m.group( BUILD_SEPARATOR_INDEX ); + buildSpecifier = nullIfEmpty( m.group( BUILD_SPECIFIER_INDEX ) ); + } + } + else + { + // Annotation was "SNAPSHOT" so populate the build specifier with that data + buildSeparator = m.group( ANNOTATION_SEPARATOR_INDEX ); + buildSpecifier = nullIfEmpty( m.group( ANNOTATION_INDEX ) ); + } + } + else + { + throw new VersionParseException( "Unable to parse the version string: \"" + version + "\"" ); + } + } + + public boolean isSnapshot() + { + return ArtifactUtils.isSnapshot( strVersion ); + } + + public String toString() + { + return strVersion; + } + + protected static String getVersionString( Version info, String buildSpecifier, String buildSeparator ) + { + StringBuilder sb = new StringBuilder(); + + if ( info.digits != null ) + { + sb.append( joinDigitString( info.digits ) ); + } + + if ( StringUtils.isNotEmpty( info.annotation ) ) + { + sb.append( StringUtils.defaultString( info.annotationSeparator ) ); + sb.append( info.annotation ); + } + + if ( StringUtils.isNotEmpty( info.annotationRevision ) ) + { + if ( StringUtils.isEmpty( info.annotation ) ) + { + sb.append( StringUtils.defaultString( info.annotationSeparator ) ); + } + else + { + sb.append( StringUtils.defaultString( info.annotationRevSeparator ) ); + } + sb.append( info.annotationRevision ); + } + + if ( StringUtils.isNotEmpty( buildSpecifier ) ) + { + sb.append( StringUtils.defaultString( buildSeparator ) ); + sb.append( buildSpecifier ); + } + + return sb.toString(); + } + + /** + * Simply joins the items in the list with "." period + * + * @return a {@code String} containing the items in the list joined by "." period + * @param digits the list of digits {@code List} + */ + protected static String joinDigitString( List digits ) + { + return digits != null ? StringUtils.join( digits.iterator(), DIGIT_SEPARATOR_STRING ) : null; + } + + /** + * Splits the string on "." and returns a list containing each digit. + * + * @param strDigits + */ + private List parseDigits( String strDigits ) + { + return Arrays.asList( StringUtils.split( strDigits, DIGIT_SEPARATOR_STRING ) ); + } + + private static String nullIfEmpty( String s ) + { + return StringUtils.isEmpty( s ) ? null : s; + } + + public List getDigits() + { + return digits; + } + + public String getAnnotation() + { + return annotation; + } + + public String getAnnotationRevSeparator() + { + return annotationRevSeparator; + } + + public String getAnnotationRevision() + { + return annotationRevision; + } + + public String getBuildSeparator() + { + return buildSeparator; + } + + public String getBuildSpecifier() + { + return buildSpecifier; + } + + /** + * + * @param newDigits the new list of digits + * @return a new instance of Version + */ + public Version setDigits( List newDigits ) + { + return new Version( newDigits, this.annotation, this.annotationRevision, this.buildSpecifier, + this.annotationSeparator, this.annotationRevSeparator, this.buildSeparator ); + } + + /** + * + * @param newAnnotationRevision the new annotation revision + * @return a new instance of Version + */ + public Version setAnnotationRevision( String newAnnotationRevision ) + { + return new Version( this.digits, this.annotation, newAnnotationRevision, this.buildSpecifier, + this.annotationSeparator, + Objects.toString( this.annotationRevSeparator, DEFAULT_ANNOTATION_REV_SEPARATOR ), + this.buildSeparator ); + } + + /** + * + * @param newBuildSpecifier the new build specifier + * @return a new instance of Version + */ + public Version setBuildSpecifier( String newBuildSpecifier ) + { + return new Version( this.digits, this.annotation, this.annotationRevision, newBuildSpecifier, + this.annotationSeparator, this.annotationRevSeparator, + Objects.toString( this.buildSeparator, DEFAULT_BUILD_SEPARATOR ) ); + } + + /** + * @throws VersionComparisonConflictException if {@link org.eclipse.aether.version.Version} and + * {@link org.apache.maven.artifact.versioning.ArtifactVersion ArtifactVersion} give different results + */ + public int compareTo( Version other ) + throws VersionComparisonConflictException + { + int aetherComparisonResult = this.aetherVersion.compareTo( other.aetherVersion ); + int mavenComparisonResult = this.mavenArtifactVersion.compareTo( other.mavenArtifactVersion ); + + if ( aetherComparisonResult < 0 && mavenComparisonResult < 0 ) + { + return -1; + } + else if ( aetherComparisonResult == 0 && mavenComparisonResult == 0 ) + { + return 0; + } + else if ( aetherComparisonResult > 0 && mavenComparisonResult > 0 ) + { + return 1; + } + else + { + throw new VersionComparisonConflictException( this.strVersion, other.strVersion, aetherComparisonResult, + mavenComparisonResult ); + } + } + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionComparisonConflictException.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionComparisonConflictException.java index 12fad4fea..441692eb7 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionComparisonConflictException.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionComparisonConflictException.java @@ -1,53 +1,53 @@ -package org.apache.maven.shared.release.versions; - -/* - * 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. - */ - -/** - * - */ -public class VersionComparisonConflictException - extends RuntimeException -{ - - private final String lhsVersion; - - private final String rhsVersion; - - private int aetherComparisonResult; - - private int mavenComparisonResult; - - public VersionComparisonConflictException( String lhsVersion, String rhsVersion, int aetherComparisonResult, - int mavenComparisonResult ) - { - this.lhsVersion = lhsVersion; - this.rhsVersion = rhsVersion; - this.aetherComparisonResult = aetherComparisonResult; - this.mavenComparisonResult = mavenComparisonResult; - } - - @Override - public String getMessage() - { - return "Conflict when comparing " + lhsVersion + " with " + rhsVersion + "; Aether: " + aetherComparisonResult - + "; Maven: " + mavenComparisonResult; - } - -} +package org.apache.maven.shared.release.versions; + +/* + * 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. + */ + +/** + * + */ +public class VersionComparisonConflictException + extends RuntimeException +{ + + private final String lhsVersion; + + private final String rhsVersion; + + private int aetherComparisonResult; + + private int mavenComparisonResult; + + public VersionComparisonConflictException( String lhsVersion, String rhsVersion, int aetherComparisonResult, + int mavenComparisonResult ) + { + this.lhsVersion = lhsVersion; + this.rhsVersion = rhsVersion; + this.aetherComparisonResult = aetherComparisonResult; + this.mavenComparisonResult = mavenComparisonResult; + } + + @Override + public String getMessage() + { + return "Conflict when comparing " + lhsVersion + " with " + rhsVersion + "; Aether: " + aetherComparisonResult + + "; Maven: " + mavenComparisonResult; + } + +} diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionParseException.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionParseException.java index eb2a0308d..d37cd9218 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionParseException.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/VersionParseException.java @@ -1,32 +1,32 @@ -package org.apache.maven.shared.release.versions; - -/* - * 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. - */ - -/** - * - */ -public class VersionParseException - extends Exception -{ - public VersionParseException( String message ) - { - super( message ); - } -} +package org.apache.maven.shared.release.versions; + +/* + * 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. + */ + +/** + * + */ +public class VersionParseException + extends Exception +{ + public VersionParseException( String message ) + { + super( message ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java index 889417f25..a646dfcc1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultNamingPolicy.java @@ -1,42 +1,42 @@ -package org.apache.maven.shared.release.policies; - -/* - * 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.shared.release.policy.PolicyException; -import org.apache.maven.shared.release.policy.naming.NamingPolicy; -import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; -import org.apache.maven.shared.release.policy.naming.NamingPolicyResult; -import org.codehaus.plexus.component.annotations.Component; - -/** - * - * @author Robert Scholte - * @since 3.0.0 - */ -@Component( role = NamingPolicy.class, hint = "default" ) -public class DefaultNamingPolicy implements NamingPolicy -{ - @Override - public NamingPolicyResult getName( NamingPolicyRequest request ) - throws PolicyException - { - return new NamingPolicyResult().setName( request.getArtifactId() + "-" + request.getVersion() ); - } -} +package org.apache.maven.shared.release.policies; + +/* + * 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.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.naming.NamingPolicy; +import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; +import org.apache.maven.shared.release.policy.naming.NamingPolicyResult; +import org.codehaus.plexus.component.annotations.Component; + +/** + * + * @author Robert Scholte + * @since 3.0.0 + */ +@Component( role = NamingPolicy.class, hint = "default" ) +public class DefaultNamingPolicy implements NamingPolicy +{ + @Override + public NamingPolicyResult getName( NamingPolicyRequest request ) + throws PolicyException + { + return new NamingPolicyResult().setName( request.getArtifactId() + "-" + request.getVersion() ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java index 7244337a9..3f323719a 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/policies/DefaultVersionPolicy.java @@ -1,56 +1,56 @@ -package org.apache.maven.shared.release.policies; - -/* - * 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.shared.release.policy.PolicyException; -import org.apache.maven.shared.release.policy.version.VersionPolicy; -import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; -import org.apache.maven.shared.release.policy.version.VersionPolicyResult; -import org.apache.maven.shared.release.versions.DefaultVersionInfo; -import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; - -/** - * - * @author Robert Scholte - */ -@Component( role = VersionPolicy.class, hint = "default" ) -public class DefaultVersionPolicy - implements VersionPolicy -{ - - @Override - public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException - { - String releaseVersion = new DefaultVersionInfo( request.getVersion() ).getReleaseVersionString(); - return new VersionPolicyResult().setVersion( releaseVersion ); - } - - @Override - public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException - { - String developmentVersion = - new DefaultVersionInfo( request.getVersion() ).getNextVersion().getSnapshotVersionString(); - return new VersionPolicyResult().setVersion( developmentVersion ); - } - -} +package org.apache.maven.shared.release.policies; + +/* + * 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.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; +import org.apache.maven.shared.release.policy.version.VersionPolicyResult; +import org.apache.maven.shared.release.versions.DefaultVersionInfo; +import org.apache.maven.shared.release.versions.VersionParseException; +import org.codehaus.plexus.component.annotations.Component; + +/** + * + * @author Robert Scholte + */ +@Component( role = VersionPolicy.class, hint = "default" ) +public class DefaultVersionPolicy + implements VersionPolicy +{ + + @Override + public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException + { + String releaseVersion = new DefaultVersionInfo( request.getVersion() ).getReleaseVersionString(); + return new VersionPolicyResult().setVersion( releaseVersion ); + } + + @Override + public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException + { + String developmentVersion = + new DefaultVersionInfo( request.getVersion() ).getNextVersion().getSnapshotVersionString(); + return new VersionPolicyResult().setVersion( developmentVersion ); + } + +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/MavenCoordinate.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/MavenCoordinate.java index fcf8b014d..69b08e172 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/MavenCoordinate.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/MavenCoordinate.java @@ -1,39 +1,39 @@ -package org.apache.maven.shared.release.transform; - -/* - * 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. - */ - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public interface MavenCoordinate -{ - String getGroupId(); - - String getArtifactId(); - - String getVersion(); - - void setVersion( String version ); - - // @todo helper method during refactoring, will be removed - String getName(); -} +package org.apache.maven.shared.release.transform; + +/* + * 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. + */ + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public interface MavenCoordinate +{ + String getGroupId(); + + String getArtifactId(); + + String getVersion(); + + void setVersion( String version ); + + // @todo helper method during refactoring, will be removed + String getName(); +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETL.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETL.java index 5dda9e59c..e0c255058 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETL.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETL.java @@ -1,43 +1,43 @@ -package org.apache.maven.shared.release.transform; - -/* - * 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.model.Model; -import org.apache.maven.shared.release.ReleaseExecutionException; - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public interface ModelETL -{ - void extract( File pomFile ) throws ReleaseExecutionException; - - void transform(); - - void load( File pomFile ) throws ReleaseExecutionException; - - // will be removed once transform() is implemented - @Deprecated - Model getModel(); -} +package org.apache.maven.shared.release.transform; + +/* + * 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.model.Model; +import org.apache.maven.shared.release.ReleaseExecutionException; + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public interface ModelETL +{ + void extract( File pomFile ) throws ReleaseExecutionException; + + void transform(); + + void load( File pomFile ) throws ReleaseExecutionException; + + // will be removed once transform() is implemented + @Deprecated + Model getModel(); +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLFactory.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLFactory.java index bdbb9a3e7..4748edc93 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLFactory.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLFactory.java @@ -1,30 +1,30 @@ -package org.apache.maven.shared.release.transform; - -/* - * 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. - */ - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public interface ModelETLFactory -{ - ModelETL newInstance( ModelETLRequest request ); -} +package org.apache.maven.shared.release.transform; + +/* + * 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. + */ + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public interface ModelETLFactory +{ + ModelETL newInstance( ModelETLRequest request ); +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLRequest.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLRequest.java index 22ec8b683..ae57d1f55 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLRequest.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/ModelETLRequest.java @@ -1,67 +1,67 @@ -package org.apache.maven.shared.release.transform; - -/* - * 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.project.MavenProject; -import org.apache.maven.shared.release.config.ReleaseDescriptor; - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public class ModelETLRequest -{ - private String lineSeparator; - - private MavenProject project; - - private ReleaseDescriptor releaseDescriptor; - - public String getLineSeparator() - { - return lineSeparator; - } - - public void setLineSeparator( String lineSeparator ) - { - this.lineSeparator = lineSeparator; - } - - public MavenProject getProject() - { - return project; - } - - public void setProject( MavenProject project ) - { - this.project = project; - } - - public ReleaseDescriptor getReleaseDescriptor() - { - return releaseDescriptor; - } - - public void setReleaseDescriptor( ReleaseDescriptor releaseDescriptor ) - { - this.releaseDescriptor = releaseDescriptor; - } +package org.apache.maven.shared.release.transform; + +/* + * 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.project.MavenProject; +import org.apache.maven.shared.release.config.ReleaseDescriptor; + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public class ModelETLRequest +{ + private String lineSeparator; + + private MavenProject project; + + private ReleaseDescriptor releaseDescriptor; + + public String getLineSeparator() + { + return lineSeparator; + } + + public void setLineSeparator( String lineSeparator ) + { + this.lineSeparator = lineSeparator; + } + + public MavenProject getProject() + { + return project; + } + + public void setProject( MavenProject project ) + { + this.project = project; + } + + public ReleaseDescriptor getReleaseDescriptor() + { + return releaseDescriptor; + } + + public void setReleaseDescriptor( ReleaseDescriptor releaseDescriptor ) + { + this.releaseDescriptor = releaseDescriptor; + } } \ No newline at end of file diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomBuild.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomBuild.java index 809bab6e7..433c8f49c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomBuild.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomBuild.java @@ -1,329 +1,329 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Extension; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginManagement; -import org.apache.maven.model.Resource; -import org.jdom.Element; -/** - * JDom implementation of poms BUILD element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomBuild - extends Build -{ - private final Element build; - - public JDomBuild( Element build ) - { - this.build = build; - } - - @Override - public void addExtension( Extension extension ) - { - throw new UnsupportedOperationException(); - } - - @Override - public List getExtensions() - { - Element extensionsElm = build.getChild( "extensions", build.getNamespace() ); - if ( extensionsElm == null ) - { - return Collections.emptyList(); - } - else - { - List extensionElms = extensionsElm.getChildren( "extension", build.getNamespace() ); - - List extensions = new ArrayList<>( extensionElms.size() ); - for ( Element extensionElm : extensionElms ) - { - extensions.add( new JDomExtension( extensionElm ) ); - } - return extensions; - } - } - - @Override - public String getOutputDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getScriptSourceDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getSourceDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getTestOutputDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getTestSourceDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeExtension( Extension extension ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setExtensions( List extensions ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setOutputDirectory( String outputDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setScriptSourceDirectory( String scriptSourceDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setSourceDirectory( String sourceDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setTestOutputDirectory( String testOutputDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setTestSourceDirectory( String testSourceDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void addFilter( String string ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void addResource( Resource resource ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void addTestResource( Resource resource ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getDefaultGoal() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getFilters() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getFinalName() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getResources() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getTestResources() - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeFilter( String string ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeResource( Resource resource ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeTestResource( Resource resource ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setDefaultGoal( String defaultGoal ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setDirectory( String directory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setFilters( List filters ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setFinalName( String finalName ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setResources( List resources ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setTestResources( List testResources ) - { - throw new UnsupportedOperationException(); - } - - @Override - public PluginManagement getPluginManagement() - { - Element pluginManagementElm = build.getChild( "pluginManagement", build.getNamespace() ); - if ( pluginManagementElm == null ) - { - return null; - } - else - { - return new JDomPluginManagement( pluginManagementElm ); - } - } - - @Override - public void setPluginManagement( PluginManagement pluginManagement ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void addPlugin( Plugin plugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public List getPlugins() - { - Element pluginsElm = build.getChild( "plugins", build.getNamespace() ); - if ( pluginsElm == null ) - { - return Collections.emptyList(); - } - else - { - List pluginElms = - pluginsElm.getChildren( "plugin", build.getNamespace() ); - - List plugins = new ArrayList<>( pluginElms.size() ); - - for ( Element pluginElm : pluginElms ) - { - plugins.add( new JDomPlugin( pluginElm ) ); - } - - return plugins; - } - } - - @Override - public void removePlugin( Plugin plugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setPlugins( List plugins ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void flushPluginMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public Map getPluginsAsMap() - { - throw new UnsupportedOperationException(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Extension; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.Resource; +import org.jdom.Element; +/** + * JDom implementation of poms BUILD element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomBuild + extends Build +{ + private final Element build; + + public JDomBuild( Element build ) + { + this.build = build; + } + + @Override + public void addExtension( Extension extension ) + { + throw new UnsupportedOperationException(); + } + + @Override + public List getExtensions() + { + Element extensionsElm = build.getChild( "extensions", build.getNamespace() ); + if ( extensionsElm == null ) + { + return Collections.emptyList(); + } + else + { + List extensionElms = extensionsElm.getChildren( "extension", build.getNamespace() ); + + List extensions = new ArrayList<>( extensionElms.size() ); + for ( Element extensionElm : extensionElms ) + { + extensions.add( new JDomExtension( extensionElm ) ); + } + return extensions; + } + } + + @Override + public String getOutputDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getScriptSourceDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getSourceDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getTestOutputDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getTestSourceDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeExtension( Extension extension ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExtensions( List extensions ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setOutputDirectory( String outputDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setScriptSourceDirectory( String scriptSourceDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setSourceDirectory( String sourceDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setTestOutputDirectory( String testOutputDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setTestSourceDirectory( String testSourceDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void addFilter( String string ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void addResource( Resource resource ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void addTestResource( Resource resource ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getDefaultGoal() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getFilters() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getFinalName() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getResources() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getTestResources() + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeFilter( String string ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeResource( Resource resource ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeTestResource( Resource resource ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setDefaultGoal( String defaultGoal ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setDirectory( String directory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setFilters( List filters ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setFinalName( String finalName ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setResources( List resources ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setTestResources( List testResources ) + { + throw new UnsupportedOperationException(); + } + + @Override + public PluginManagement getPluginManagement() + { + Element pluginManagementElm = build.getChild( "pluginManagement", build.getNamespace() ); + if ( pluginManagementElm == null ) + { + return null; + } + else + { + return new JDomPluginManagement( pluginManagementElm ); + } + } + + @Override + public void setPluginManagement( PluginManagement pluginManagement ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void addPlugin( Plugin plugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public List getPlugins() + { + Element pluginsElm = build.getChild( "plugins", build.getNamespace() ); + if ( pluginsElm == null ) + { + return Collections.emptyList(); + } + else + { + List pluginElms = + pluginsElm.getChildren( "plugin", build.getNamespace() ); + + List plugins = new ArrayList<>( pluginElms.size() ); + + for ( Element pluginElm : pluginElms ) + { + plugins.add( new JDomPlugin( pluginElm ) ); + } + + return plugins; + } + } + + @Override + public void removePlugin( Plugin plugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setPlugins( List plugins ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void flushPluginMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public Map getPluginsAsMap() + { + throw new UnsupportedOperationException(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependency.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependency.java index aa9a43da6..96b99d1fd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependency.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependency.java @@ -1,169 +1,169 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.List; - -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Exclusion; -import org.apache.maven.shared.release.transform.MavenCoordinate; -import org.jdom.Element; - -/** - * JDom implementation of poms DEPENDENCY element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomDependency extends Dependency implements MavenCoordinate -{ - private final MavenCoordinate coordinate; - - public JDomDependency( Element dependency ) - { - this.coordinate = new JDomMavenCoordinate( dependency ); - } - - @Override - public void addExclusion( Exclusion exclusion ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getArtifactId() - { - return coordinate.getArtifactId(); - } - - @Override - public String getClassifier() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getExclusions() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getGroupId() - { - return coordinate.getGroupId(); - } - - @Override - public String getScope() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getSystemPath() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getType() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getVersion() - { - return coordinate.getVersion(); - } - - @Override - public boolean isOptional() - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeExclusion( Exclusion exclusion ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setArtifactId( String artifactId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setClassifier( String classifier ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setExclusions( List exclusions ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGroupId( String groupId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setOptional( boolean optional ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setScope( String scope ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setSystemPath( String systemPath ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setType( String type ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setVersion( String version ) - { - coordinate.setVersion( version ); - } - - @Override - public String getName() - { - return "dependency"; - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.List; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Exclusion; +import org.apache.maven.shared.release.transform.MavenCoordinate; +import org.jdom.Element; + +/** + * JDom implementation of poms DEPENDENCY element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomDependency extends Dependency implements MavenCoordinate +{ + private final MavenCoordinate coordinate; + + public JDomDependency( Element dependency ) + { + this.coordinate = new JDomMavenCoordinate( dependency ); + } + + @Override + public void addExclusion( Exclusion exclusion ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getArtifactId() + { + return coordinate.getArtifactId(); + } + + @Override + public String getClassifier() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getExclusions() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getGroupId() + { + return coordinate.getGroupId(); + } + + @Override + public String getScope() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getSystemPath() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getType() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getVersion() + { + return coordinate.getVersion(); + } + + @Override + public boolean isOptional() + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeExclusion( Exclusion exclusion ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setArtifactId( String artifactId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setClassifier( String classifier ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExclusions( List exclusions ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGroupId( String groupId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setOptional( boolean optional ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setScope( String scope ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setSystemPath( String systemPath ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setType( String type ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setVersion( String version ) + { + coordinate.setVersion( version ); + } + + @Override + public String getName() + { + return "dependency"; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagement.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagement.java index bb53c855f..aade7c8ef 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagement.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagement.java @@ -1,87 +1,87 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.jdom.Element; - -/** - * JDom implementation of poms DEPENDENCYMANAGEMENT element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomDependencyManagement extends DependencyManagement -{ - private final Element dependencyManagement; - - public JDomDependencyManagement( Element dependencyManagement ) - { - this.dependencyManagement = dependencyManagement; - } - - @Override - public void addDependency( Dependency dependency ) - { - throw new UnsupportedOperationException(); - } - - @Override - public List getDependencies() - { - Element dependenciesElm = dependencyManagement.getChild( "dependencies", dependencyManagement.getNamespace() ); - if ( dependenciesElm == null ) - { - return Collections.emptyList(); - } - else - { - List dependencyElms = - dependenciesElm.getChildren( "dependency", dependencyManagement.getNamespace() ); - - List dependencies = new ArrayList<>( dependencyElms.size() ); - - for ( Element dependencyElm : dependencyElms ) - { - dependencies.add( new JDomDependency( dependencyElm ) ); - } - - return dependencies; - } - } - - @Override - public void removeDependency( Dependency dependency ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setDependencies( List dependencies ) - { - throw new UnsupportedOperationException(); - } - -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.jdom.Element; + +/** + * JDom implementation of poms DEPENDENCYMANAGEMENT element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomDependencyManagement extends DependencyManagement +{ + private final Element dependencyManagement; + + public JDomDependencyManagement( Element dependencyManagement ) + { + this.dependencyManagement = dependencyManagement; + } + + @Override + public void addDependency( Dependency dependency ) + { + throw new UnsupportedOperationException(); + } + + @Override + public List getDependencies() + { + Element dependenciesElm = dependencyManagement.getChild( "dependencies", dependencyManagement.getNamespace() ); + if ( dependenciesElm == null ) + { + return Collections.emptyList(); + } + else + { + List dependencyElms = + dependenciesElm.getChildren( "dependency", dependencyManagement.getNamespace() ); + + List dependencies = new ArrayList<>( dependencyElms.size() ); + + for ( Element dependencyElm : dependencyElms ) + { + dependencies.add( new JDomDependency( dependencyElm ) ); + } + + return dependencies; + } + } + + @Override + public void removeDependency( Dependency dependency ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setDependencies( List dependencies ) + { + throw new UnsupportedOperationException(); + } + +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomExtension.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomExtension.java index 5da2b0e51..a5dca63f3 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomExtension.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomExtension.java @@ -1,82 +1,82 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.model.Extension; -import org.apache.maven.shared.release.transform.MavenCoordinate; -import org.jdom.Element; - -/** - * JDom implementation of poms EXTENSION element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomExtension extends Extension implements MavenCoordinate -{ - private final MavenCoordinate coordinate; - - public JDomExtension( Element extension ) - { - this.coordinate = new JDomMavenCoordinate( extension ); - } - - @Override - public String getArtifactId() - { - return coordinate.getArtifactId(); - } - - @Override - public String getGroupId() - { - return coordinate.getGroupId(); - } - - @Override - public String getVersion() - { - return coordinate.getVersion(); - } - - @Override - public void setArtifactId( String artifactId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGroupId( String groupId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setVersion( String version ) - { - coordinate.setVersion( version ); - } - - @Override - public String getName() - { - return "extension"; - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.model.Extension; +import org.apache.maven.shared.release.transform.MavenCoordinate; +import org.jdom.Element; + +/** + * JDom implementation of poms EXTENSION element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomExtension extends Extension implements MavenCoordinate +{ + private final MavenCoordinate coordinate; + + public JDomExtension( Element extension ) + { + this.coordinate = new JDomMavenCoordinate( extension ); + } + + @Override + public String getArtifactId() + { + return coordinate.getArtifactId(); + } + + @Override + public String getGroupId() + { + return coordinate.getGroupId(); + } + + @Override + public String getVersion() + { + return coordinate.getVersion(); + } + + @Override + public void setArtifactId( String artifactId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGroupId( String groupId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setVersion( String version ) + { + coordinate.setVersion( version ); + } + + @Override + public String getName() + { + return "extension"; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomMavenCoordinate.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomMavenCoordinate.java index b2a7ef353..83b927a4c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomMavenCoordinate.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomMavenCoordinate.java @@ -1,82 +1,82 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.shared.release.transform.MavenCoordinate; -import org.jdom.Element; - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomMavenCoordinate implements MavenCoordinate -{ - private final Element element; - - public JDomMavenCoordinate( Element elm ) - { - this.element = elm; - } - - @Override - public String getGroupId() - { - return element.getChildTextTrim( "groupId", element.getNamespace() ); - } - - @Override - public String getArtifactId() - { - return element.getChildTextTrim( "artifactId", element.getNamespace() ); - } - - @Override - public String getVersion() - { - Element version = getVersionElement(); - if ( version == null ) - { - return null; - } - else - { - return version.getTextTrim(); - } - - } - - private Element getVersionElement() - { - return element.getChild( "version", element.getNamespace() ); - } - - @Override - public void setVersion( String version ) - { - JDomUtils.rewriteValue( getVersionElement(), version ); - } - - @Override - public String getName() - { - return element.getName(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.shared.release.transform.MavenCoordinate; +import org.jdom.Element; + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomMavenCoordinate implements MavenCoordinate +{ + private final Element element; + + public JDomMavenCoordinate( Element elm ) + { + this.element = elm; + } + + @Override + public String getGroupId() + { + return element.getChildTextTrim( "groupId", element.getNamespace() ); + } + + @Override + public String getArtifactId() + { + return element.getChildTextTrim( "artifactId", element.getNamespace() ); + } + + @Override + public String getVersion() + { + Element version = getVersionElement(); + if ( version == null ) + { + return null; + } + else + { + return version.getTextTrim(); + } + + } + + private Element getVersionElement() + { + return element.getChild( "version", element.getNamespace() ); + } + + @Override + public void setVersion( String version ) + { + JDomUtils.rewriteValue( getVersionElement(), version ); + } + + @Override + public String getName() + { + return element.getName(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModel.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModel.java index bb477b6ad..88271ba26 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModel.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModel.java @@ -1,227 +1,227 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; -import org.apache.maven.model.Profile; -import org.apache.maven.model.Reporting; -import org.apache.maven.model.Scm; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.Text; - -/** - * JDom implementation of poms PROJECT element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomModel extends Model -{ - private final Element project; - - private final JDomModelBase modelBase; - - public JDomModel( Document document ) - { - this( document.getRootElement() ); - } - - public JDomModel( Element project ) - { - this.project = project; - this.modelBase = new JDomModelBase( project ); - } - - @Override - public Build getBuild() - { - return modelBase.getBuild(); - } - - @Override - public List getDependencies() - { - return modelBase.getDependencies(); - } - - @Override - public DependencyManagement getDependencyManagement() - { - return modelBase.getDependencyManagement(); - } - - @Override - public Parent getParent() - { - Element elm = getParentElement(); - if ( elm == null ) - { - return null; - } - else - { - // this way scm setters change DOM tree immediately - return new JDomParent( elm ); - } - } - - private Element getParentElement() - { - return project.getChild( "parent", project.getNamespace() ); - } - - @Override - public List getProfiles() - { - Element profilesElm = project.getChild( "profiles", project.getNamespace() ); - if ( profilesElm == null ) - { - return Collections.emptyList(); - } - else - { - List profileElms = profilesElm.getChildren( "profile", project.getNamespace() ); - - List profiles = new ArrayList<>( profileElms.size() ); - - for ( Element profileElm : profileElms ) - { - profiles.add( new JDomProfile( profileElm ) ); - } - - return profiles; - } - } - - - @Override - public Properties getProperties() - { - Element properties = project.getChild( "properties", project.getNamespace() ); - - if ( properties == null ) - { - return null; - } - else - { - return new JDomProperties( properties ); - } - } - - @Override - public Reporting getReporting() - { - Element reporting = project.getChild( "reporting", project.getNamespace() ); - - if ( reporting == null ) - { - return null; - } - else - { - return new JDomReporting( reporting ); - } - } - - @Override - public void setScm( Scm scm ) - { - if ( scm == null ) - { - JDomUtils.rewriteElement( "scm", null, project, project.getNamespace() ); - } - else - { - Element scmRoot = new Element( "scm" ); - scmRoot.addContent( "\n " ); - - // Write current values to JDom tree - Scm jdomScm = new JDomScm( scmRoot ); - jdomScm.setConnection( scm.getConnection() ); - jdomScm.setDeveloperConnection( scm.getDeveloperConnection() ); - jdomScm.setTag( scm.getTag() ); - jdomScm.setUrl( scm.getUrl() ); - - project.addContent( "\n " ).addContent( scmRoot ).addContent( "\n" ); - } - } - - @Override - public Scm getScm() - { - Element elm = project.getChild( "scm", project.getNamespace() ); - if ( elm == null ) - { - return null; - } - else - { - // this way scm setters change DOM tree immediately - return new JDomScm( elm ); - } - } - - @Override - public void setVersion( String version ) - { - Element versionElement = project.getChild( "version", project.getNamespace() ); - - String parentVersion; - Element parent = getParentElement(); - if ( parent != null ) - { - parentVersion = parent.getChildTextTrim( "version", project.getNamespace() ); - } - else - { - parentVersion = null; - } - - if ( versionElement == null ) - { - if ( !version.equals( parentVersion ) ) - { - // we will add this after artifactId, since it was missing but different from the inherited version - Element artifactIdElement = project.getChild( "artifactId", project.getNamespace() ); - int index = project.indexOf( artifactIdElement ); - - versionElement = new Element( "version", project.getNamespace() ); - versionElement.setText( version ); - project.addContent( index + 1, new Text( "\n " ) ); - project.addContent( index + 2, versionElement ); - } - } - else - { - JDomUtils.rewriteValue( versionElement, version ); - } - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; +import org.apache.maven.model.Profile; +import org.apache.maven.model.Reporting; +import org.apache.maven.model.Scm; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.Text; + +/** + * JDom implementation of poms PROJECT element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomModel extends Model +{ + private final Element project; + + private final JDomModelBase modelBase; + + public JDomModel( Document document ) + { + this( document.getRootElement() ); + } + + public JDomModel( Element project ) + { + this.project = project; + this.modelBase = new JDomModelBase( project ); + } + + @Override + public Build getBuild() + { + return modelBase.getBuild(); + } + + @Override + public List getDependencies() + { + return modelBase.getDependencies(); + } + + @Override + public DependencyManagement getDependencyManagement() + { + return modelBase.getDependencyManagement(); + } + + @Override + public Parent getParent() + { + Element elm = getParentElement(); + if ( elm == null ) + { + return null; + } + else + { + // this way scm setters change DOM tree immediately + return new JDomParent( elm ); + } + } + + private Element getParentElement() + { + return project.getChild( "parent", project.getNamespace() ); + } + + @Override + public List getProfiles() + { + Element profilesElm = project.getChild( "profiles", project.getNamespace() ); + if ( profilesElm == null ) + { + return Collections.emptyList(); + } + else + { + List profileElms = profilesElm.getChildren( "profile", project.getNamespace() ); + + List profiles = new ArrayList<>( profileElms.size() ); + + for ( Element profileElm : profileElms ) + { + profiles.add( new JDomProfile( profileElm ) ); + } + + return profiles; + } + } + + + @Override + public Properties getProperties() + { + Element properties = project.getChild( "properties", project.getNamespace() ); + + if ( properties == null ) + { + return null; + } + else + { + return new JDomProperties( properties ); + } + } + + @Override + public Reporting getReporting() + { + Element reporting = project.getChild( "reporting", project.getNamespace() ); + + if ( reporting == null ) + { + return null; + } + else + { + return new JDomReporting( reporting ); + } + } + + @Override + public void setScm( Scm scm ) + { + if ( scm == null ) + { + JDomUtils.rewriteElement( "scm", null, project, project.getNamespace() ); + } + else + { + Element scmRoot = new Element( "scm" ); + scmRoot.addContent( "\n " ); + + // Write current values to JDom tree + Scm jdomScm = new JDomScm( scmRoot ); + jdomScm.setConnection( scm.getConnection() ); + jdomScm.setDeveloperConnection( scm.getDeveloperConnection() ); + jdomScm.setTag( scm.getTag() ); + jdomScm.setUrl( scm.getUrl() ); + + project.addContent( "\n " ).addContent( scmRoot ).addContent( "\n" ); + } + } + + @Override + public Scm getScm() + { + Element elm = project.getChild( "scm", project.getNamespace() ); + if ( elm == null ) + { + return null; + } + else + { + // this way scm setters change DOM tree immediately + return new JDomScm( elm ); + } + } + + @Override + public void setVersion( String version ) + { + Element versionElement = project.getChild( "version", project.getNamespace() ); + + String parentVersion; + Element parent = getParentElement(); + if ( parent != null ) + { + parentVersion = parent.getChildTextTrim( "version", project.getNamespace() ); + } + else + { + parentVersion = null; + } + + if ( versionElement == null ) + { + if ( !version.equals( parentVersion ) ) + { + // we will add this after artifactId, since it was missing but different from the inherited version + Element artifactIdElement = project.getChild( "artifactId", project.getNamespace() ); + int index = project.indexOf( artifactIdElement ); + + versionElement = new Element( "version", project.getNamespace() ); + versionElement.setText( version ); + project.addContent( index + 1, new Text( "\n " ) ); + project.addContent( index + 2, versionElement ); + } + } + else + { + JDomUtils.rewriteValue( versionElement, version ); + } + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelBase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelBase.java index 74e45229b..cdc6442ce 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelBase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelBase.java @@ -1,94 +1,94 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.maven.model.Build; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.jdom.Element; - -/** - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomModelBase -{ - private final Element modelBase; - - public JDomModelBase( Element modelBase ) - { - this.modelBase = modelBase; - } - - public Build getBuild() - { - Element elm = modelBase.getChild( "build", modelBase.getNamespace() ); - if ( elm == null ) - { - return null; - } - else - { - // this way build setters change DOM tree immediately - return new JDomBuild( elm ); - } - } - - public List getDependencies() - { - Element dependenciesElm = modelBase.getChild( "dependencies", modelBase.getNamespace() ); - if ( dependenciesElm == null ) - { - return Collections.emptyList(); - } - else - { - List dependencyElms = dependenciesElm.getChildren( "dependency", modelBase.getNamespace() ); - - List dependencies = new ArrayList<>( dependencyElms.size() ); - - for ( Element dependencyElm : dependencyElms ) - { - dependencies.add( new JDomDependency( dependencyElm ) ); - } - - return dependencies; - } - } - - public DependencyManagement getDependencyManagement() - { - Element elm = modelBase.getChild( "dependencyManagement", modelBase.getNamespace() ); - if ( elm == null ) - { - return null; - } - else - { - // this way build setters change DOM tree immediately - return new JDomDependencyManagement( elm ); - } - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.maven.model.Build; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.jdom.Element; + +/** + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomModelBase +{ + private final Element modelBase; + + public JDomModelBase( Element modelBase ) + { + this.modelBase = modelBase; + } + + public Build getBuild() + { + Element elm = modelBase.getChild( "build", modelBase.getNamespace() ); + if ( elm == null ) + { + return null; + } + else + { + // this way build setters change DOM tree immediately + return new JDomBuild( elm ); + } + } + + public List getDependencies() + { + Element dependenciesElm = modelBase.getChild( "dependencies", modelBase.getNamespace() ); + if ( dependenciesElm == null ) + { + return Collections.emptyList(); + } + else + { + List dependencyElms = dependenciesElm.getChildren( "dependency", modelBase.getNamespace() ); + + List dependencies = new ArrayList<>( dependencyElms.size() ); + + for ( Element dependencyElm : dependencyElms ) + { + dependencies.add( new JDomDependency( dependencyElm ) ); + } + + return dependencies; + } + } + + public DependencyManagement getDependencyManagement() + { + Element elm = modelBase.getChild( "dependencyManagement", modelBase.getNamespace() ); + if ( elm == null ) + { + return null; + } + else + { + // this way build setters change DOM tree immediately + return new JDomDependencyManagement( elm ); + } + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETL.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETL.java index 49df5abb8..e0b845788 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETL.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETL.java @@ -1,234 +1,234 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.maven.model.Model; -import org.apache.maven.project.MavenProject; -import org.apache.maven.shared.release.ReleaseExecutionException; -import org.apache.maven.shared.release.config.ReleaseDescriptor; -import org.apache.maven.shared.release.transform.ModelETL; -import org.apache.maven.shared.release.util.ReleaseUtil; -import org.codehaus.plexus.util.WriterFactory; -import org.jdom.CDATA; -import org.jdom.Comment; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.Namespace; -import org.jdom.filter.ContentFilter; -import org.jdom.filter.ElementFilter; -import org.jdom.input.SAXBuilder; -import org.jdom.output.Format; -import org.jdom.output.XMLOutputter; - -/** - * JDom implementation for extracting, transform, loading the Model (pom.xml) - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomModelETL implements ModelETL -{ - private ReleaseDescriptor releaseDescriptor; - - private MavenProject project; - - private Document document; - - private String intro = null; - private String outtro = null; - - private String ls = ReleaseUtil.LS; - - public void setLs( String ls ) - { - this.ls = ls; - } - - public void setReleaseDescriptor( ReleaseDescriptor releaseDescriptor ) - { - this.releaseDescriptor = releaseDescriptor; - } - - public void setProject( MavenProject project ) - { - this.project = project; - } - - @Override - public void extract( File pomFile ) throws ReleaseExecutionException - { - try - { - String content = ReleaseUtil.readXmlFile( pomFile, ls ); - // we need to eliminate any extra whitespace inside elements, as JDOM will nuke it - content = content.replaceAll( "<([^!][^>]*?)\\s{2,}([^>]*?)>", "<$1 $2>" ); - content = content.replaceAll( "(\\s{2,})/>", "$1 />" ); - - SAXBuilder builder = new SAXBuilder(); - document = builder.build( new StringReader( content ) ); - - // Normalize line endings to platform's style (XML processors like JDOM normalize line endings to "\n" as - // per section 2.11 of the XML spec) - normaliseLineEndings( document ); - - // rewrite DOM as a string to find differences, since text outside the root element is not tracked - StringWriter w = new StringWriter(); - Format format = Format.getRawFormat(); - format.setLineSeparator( ls ); - XMLOutputter out = new XMLOutputter( format ); - out.output( document.getRootElement(), w ); - - int index = content.indexOf( w.toString() ); - if ( index >= 0 ) - { - intro = content.substring( 0, index ); - outtro = content.substring( index + w.toString().length() ); - } - else - { - /* - * NOTE: Due to whitespace, attribute reordering or entity expansion the above indexOf test can easily - * fail. So let's try harder. Maybe some day, when JDOM offers a StaxBuilder and this builder employes - * XMLInputFactory2.P_REPORT_PROLOG_WHITESPACE, this whole mess can be avoided. - */ - // CHECKSTYLE_OFF: LocalFinalVariableName - final String SPACE = "\\s++"; - final String XML = "<\\?(?:(?:[^\"'>]++)|(?:\"[^\"]*+\")|(?:'[^\']*+'))*+>"; - final String INTSUB = "\\[(?:(?:[^\"'\\]]++)|(?:\"[^\"]*+\")|(?:'[^\']*+'))*+\\]"; - final String DOCTYPE = - "]++)|(?:\"[^\"]*+\")|(?:'[^\']*+')|(?:" + INTSUB + "))*+>"; - final String PI = XML; - final String COMMENT = ""; - - final String INTRO = - "(?:(?:" + SPACE + ")|(?:" + XML + ")|(?:" + DOCTYPE + ")|(?:" + COMMENT + ")|(?:" + PI + "))*"; - final String OUTRO = "(?:(?:" + SPACE + ")|(?:" + COMMENT + ")|(?:" + PI + "))*"; - final String POM = "(?s)(" + INTRO + ")(.*?)(" + OUTRO + ")"; - // CHECKSTYLE_ON: LocalFinalVariableName - - Matcher matcher = Pattern.compile( POM ).matcher( content ); - if ( matcher.matches() ) - { - intro = matcher.group( 1 ); - outtro = matcher.group( matcher.groupCount() ); - } - } - } - catch ( JDOMException | IOException e ) - { - throw new ReleaseExecutionException( "Error reading POM: " + e.getMessage(), e ); - } - } - - @Override - public void transform() - { - - } - - @Override - public void load( File targetFile ) throws ReleaseExecutionException - { - writePom( targetFile, document, releaseDescriptor, project.getModelVersion(), intro, outtro ); - } - - @Override - public Model getModel() - { - return new JDomModel( document ); - } - - private void normaliseLineEndings( Document document ) - { - for ( Iterator i = document.getDescendants( new ContentFilter( ContentFilter.COMMENT ) ); i.hasNext(); ) - { - Comment c = (Comment) i.next(); - c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); - } - for ( Iterator i = document.getDescendants( new ContentFilter( ContentFilter.CDATA ) ); i.hasNext(); ) - { - CDATA c = (CDATA) i.next(); - c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); - } - } - - private void writePom( File pomFile, Document document, ReleaseDescriptor releaseDescriptor, String modelVersion, - String intro, String outtro ) - throws ReleaseExecutionException - { - Element rootElement = document.getRootElement(); - - if ( releaseDescriptor.isAddSchema() ) - { - Namespace pomNamespace = Namespace.getNamespace( "", "http://maven.apache.org/POM/" + modelVersion ); - rootElement.setNamespace( pomNamespace ); - Namespace xsiNamespace = Namespace.getNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - rootElement.addNamespaceDeclaration( xsiNamespace ); - - if ( rootElement.getAttribute( "schemaLocation", xsiNamespace ) == null ) - { - rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/" + modelVersion - + " https://maven.apache.org/xsd/maven-" + modelVersion + ".xsd", xsiNamespace ); - } - - // the empty namespace is considered equal to the POM namespace, so match them up to avoid extra xmlns="" - ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) ); - for ( Iterator i = rootElement.getDescendants( elementFilter ); i.hasNext(); ) - { - Element e = (Element) i.next(); - e.setNamespace( pomNamespace ); - } - } - - - try ( Writer writer = WriterFactory.newXmlWriter( pomFile ) ) - { - if ( intro != null ) - { - writer.write( intro ); - } - - Format format = Format.getRawFormat(); - format.setLineSeparator( ls ); - XMLOutputter out = new XMLOutputter( format ); - out.output( document.getRootElement(), writer ); - - if ( outtro != null ) - { - writer.write( outtro ); - } - } - catch ( IOException e ) - { - throw new ReleaseExecutionException( "Error writing POM: " + e.getMessage(), e ); - } - } - -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Iterator; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.model.Model; +import org.apache.maven.project.MavenProject; +import org.apache.maven.shared.release.ReleaseExecutionException; +import org.apache.maven.shared.release.config.ReleaseDescriptor; +import org.apache.maven.shared.release.transform.ModelETL; +import org.apache.maven.shared.release.util.ReleaseUtil; +import org.codehaus.plexus.util.WriterFactory; +import org.jdom.CDATA; +import org.jdom.Comment; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.Namespace; +import org.jdom.filter.ContentFilter; +import org.jdom.filter.ElementFilter; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +/** + * JDom implementation for extracting, transform, loading the Model (pom.xml) + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomModelETL implements ModelETL +{ + private ReleaseDescriptor releaseDescriptor; + + private MavenProject project; + + private Document document; + + private String intro = null; + private String outtro = null; + + private String ls = ReleaseUtil.LS; + + public void setLs( String ls ) + { + this.ls = ls; + } + + public void setReleaseDescriptor( ReleaseDescriptor releaseDescriptor ) + { + this.releaseDescriptor = releaseDescriptor; + } + + public void setProject( MavenProject project ) + { + this.project = project; + } + + @Override + public void extract( File pomFile ) throws ReleaseExecutionException + { + try + { + String content = ReleaseUtil.readXmlFile( pomFile, ls ); + // we need to eliminate any extra whitespace inside elements, as JDOM will nuke it + content = content.replaceAll( "<([^!][^>]*?)\\s{2,}([^>]*?)>", "<$1 $2>" ); + content = content.replaceAll( "(\\s{2,})/>", "$1 />" ); + + SAXBuilder builder = new SAXBuilder(); + document = builder.build( new StringReader( content ) ); + + // Normalize line endings to platform's style (XML processors like JDOM normalize line endings to "\n" as + // per section 2.11 of the XML spec) + normaliseLineEndings( document ); + + // rewrite DOM as a string to find differences, since text outside the root element is not tracked + StringWriter w = new StringWriter(); + Format format = Format.getRawFormat(); + format.setLineSeparator( ls ); + XMLOutputter out = new XMLOutputter( format ); + out.output( document.getRootElement(), w ); + + int index = content.indexOf( w.toString() ); + if ( index >= 0 ) + { + intro = content.substring( 0, index ); + outtro = content.substring( index + w.toString().length() ); + } + else + { + /* + * NOTE: Due to whitespace, attribute reordering or entity expansion the above indexOf test can easily + * fail. So let's try harder. Maybe some day, when JDOM offers a StaxBuilder and this builder employes + * XMLInputFactory2.P_REPORT_PROLOG_WHITESPACE, this whole mess can be avoided. + */ + // CHECKSTYLE_OFF: LocalFinalVariableName + final String SPACE = "\\s++"; + final String XML = "<\\?(?:(?:[^\"'>]++)|(?:\"[^\"]*+\")|(?:'[^\']*+'))*+>"; + final String INTSUB = "\\[(?:(?:[^\"'\\]]++)|(?:\"[^\"]*+\")|(?:'[^\']*+'))*+\\]"; + final String DOCTYPE = + "]++)|(?:\"[^\"]*+\")|(?:'[^\']*+')|(?:" + INTSUB + "))*+>"; + final String PI = XML; + final String COMMENT = ""; + + final String INTRO = + "(?:(?:" + SPACE + ")|(?:" + XML + ")|(?:" + DOCTYPE + ")|(?:" + COMMENT + ")|(?:" + PI + "))*"; + final String OUTRO = "(?:(?:" + SPACE + ")|(?:" + COMMENT + ")|(?:" + PI + "))*"; + final String POM = "(?s)(" + INTRO + ")(.*?)(" + OUTRO + ")"; + // CHECKSTYLE_ON: LocalFinalVariableName + + Matcher matcher = Pattern.compile( POM ).matcher( content ); + if ( matcher.matches() ) + { + intro = matcher.group( 1 ); + outtro = matcher.group( matcher.groupCount() ); + } + } + } + catch ( JDOMException | IOException e ) + { + throw new ReleaseExecutionException( "Error reading POM: " + e.getMessage(), e ); + } + } + + @Override + public void transform() + { + + } + + @Override + public void load( File targetFile ) throws ReleaseExecutionException + { + writePom( targetFile, document, releaseDescriptor, project.getModelVersion(), intro, outtro ); + } + + @Override + public Model getModel() + { + return new JDomModel( document ); + } + + private void normaliseLineEndings( Document document ) + { + for ( Iterator i = document.getDescendants( new ContentFilter( ContentFilter.COMMENT ) ); i.hasNext(); ) + { + Comment c = (Comment) i.next(); + c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); + } + for ( Iterator i = document.getDescendants( new ContentFilter( ContentFilter.CDATA ) ); i.hasNext(); ) + { + CDATA c = (CDATA) i.next(); + c.setText( ReleaseUtil.normalizeLineEndings( c.getText(), ls ) ); + } + } + + private void writePom( File pomFile, Document document, ReleaseDescriptor releaseDescriptor, String modelVersion, + String intro, String outtro ) + throws ReleaseExecutionException + { + Element rootElement = document.getRootElement(); + + if ( releaseDescriptor.isAddSchema() ) + { + Namespace pomNamespace = Namespace.getNamespace( "", "http://maven.apache.org/POM/" + modelVersion ); + rootElement.setNamespace( pomNamespace ); + Namespace xsiNamespace = Namespace.getNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); + rootElement.addNamespaceDeclaration( xsiNamespace ); + + if ( rootElement.getAttribute( "schemaLocation", xsiNamespace ) == null ) + { + rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/" + modelVersion + + " https://maven.apache.org/xsd/maven-" + modelVersion + ".xsd", xsiNamespace ); + } + + // the empty namespace is considered equal to the POM namespace, so match them up to avoid extra xmlns="" + ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) ); + for ( Iterator i = rootElement.getDescendants( elementFilter ); i.hasNext(); ) + { + Element e = (Element) i.next(); + e.setNamespace( pomNamespace ); + } + } + + + try ( Writer writer = WriterFactory.newXmlWriter( pomFile ) ) + { + if ( intro != null ) + { + writer.write( intro ); + } + + Format format = Format.getRawFormat(); + format.setLineSeparator( ls ); + XMLOutputter out = new XMLOutputter( format ); + out.output( document.getRootElement(), writer ); + + if ( outtro != null ) + { + writer.write( outtro ); + } + } + catch ( IOException e ) + { + throw new ReleaseExecutionException( "Error writing POM: " + e.getMessage(), e ); + } + } + +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETLFactory.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETLFactory.java index 88078e0a4..26ebe5de5 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETLFactory.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomModelETLFactory.java @@ -1,46 +1,46 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.shared.release.transform.ModelETLRequest; -import org.apache.maven.shared.release.transform.ModelETLFactory; -import org.codehaus.plexus.component.annotations.Component; - -/** - * @author Robert Scholte - * @since 3.0 - */ -@Component( role = ModelETLFactory.class, hint = JDomModelETLFactory.ROLE_HINT ) -public class JDomModelETLFactory implements ModelETLFactory -{ - public static final String ROLE_HINT = "jdom-sax"; - - @Override - public JDomModelETL newInstance( ModelETLRequest request ) - { - JDomModelETL result = new JDomModelETL(); - - result.setLs( request.getLineSeparator() ); - result.setProject( request.getProject() ); - result.setReleaseDescriptor( request.getReleaseDescriptor() ); - - return result; - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.shared.release.transform.ModelETLRequest; +import org.apache.maven.shared.release.transform.ModelETLFactory; +import org.codehaus.plexus.component.annotations.Component; + +/** + * @author Robert Scholte + * @since 3.0 + */ +@Component( role = ModelETLFactory.class, hint = JDomModelETLFactory.ROLE_HINT ) +public class JDomModelETLFactory implements ModelETLFactory +{ + public static final String ROLE_HINT = "jdom-sax"; + + @Override + public JDomModelETL newInstance( ModelETLRequest request ) + { + JDomModelETL result = new JDomModelETL(); + + result.setLs( request.getLineSeparator() ); + result.setProject( request.getProject() ); + result.setReleaseDescriptor( request.getReleaseDescriptor() ); + + return result; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomParent.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomParent.java index 24f4e905d..be345df4c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomParent.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomParent.java @@ -1,93 +1,93 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.model.Parent; -import org.jdom.Element; - -/** - * JDom implementation of poms PARENT element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomParent extends Parent -{ - private Element parent; - - public JDomParent( Element parent ) - { - this.parent = parent; - } - - @Override - public String getVersion() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setVersion( String version ) - { - JDomUtils.rewriteElement( "version", version, parent, parent.getNamespace() ); - } - - @Override - public String getArtifactId() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getGroupId() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getRelativePath() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setArtifactId( String artifactId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGroupId( String groupId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setRelativePath( String relativePath ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getId() - { - throw new UnsupportedOperationException(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.model.Parent; +import org.jdom.Element; + +/** + * JDom implementation of poms PARENT element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomParent extends Parent +{ + private Element parent; + + public JDomParent( Element parent ) + { + this.parent = parent; + } + + @Override + public String getVersion() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setVersion( String version ) + { + JDomUtils.rewriteElement( "version", version, parent, parent.getNamespace() ); + } + + @Override + public String getArtifactId() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getGroupId() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getRelativePath() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setArtifactId( String artifactId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGroupId( String groupId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setRelativePath( String relativePath ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getId() + { + throw new UnsupportedOperationException(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPlugin.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPlugin.java index 2955ddcac..bf21eeab2 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPlugin.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPlugin.java @@ -1,193 +1,193 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.shared.release.transform.MavenCoordinate; -import org.jdom.Element; - -/** - * JDom implementation of poms PLUGIN element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomPlugin extends Plugin implements MavenCoordinate -{ - private Element plugin; - private final MavenCoordinate coordinate; - - public JDomPlugin( Element plugin ) - { - this.plugin = plugin; - this.coordinate = new JDomMavenCoordinate( plugin ); - } - - @Override - public void addDependency( Dependency dependency ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void addExecution( PluginExecution pluginExecution ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getArtifactId() - { - return coordinate.getArtifactId(); - } - - @Override - public List getDependencies() - { - Element dependenciesElm = plugin.getChild( "dependencies", plugin.getNamespace() ); - if ( dependenciesElm == null ) - { - return Collections.emptyList(); - } - else - { - List dependencyElms = - dependenciesElm.getChildren( "dependency", plugin.getNamespace() ); - - List dependencies = new ArrayList<>( dependencyElms.size() ); - - for ( Element dependencyElm : dependencyElms ) - { - dependencies.add( new JDomDependency( dependencyElm ) ); - } - - return dependencies; - } - } - - @Override - public List getExecutions() - { - throw new UnsupportedOperationException(); - } - - @Override - public Object getGoals() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getGroupId() - { - return coordinate.getGroupId(); - } - - @Override - public String getVersion() - { - return coordinate.getVersion(); - } - - @Override - public boolean isExtensions() - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeDependency( Dependency dependency ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void removeExecution( PluginExecution pluginExecution ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setArtifactId( String artifactId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setDependencies( List dependencies ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setExecutions( List executions ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setExtensions( boolean extensions ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGoals( Object goals ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGroupId( String groupId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setVersion( String version ) - { - coordinate.setVersion( version ); - } - - @Override - public void flushExecutionMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public Map getExecutionsAsMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getName() - { - return "plugin"; - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Dependency; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginExecution; +import org.apache.maven.shared.release.transform.MavenCoordinate; +import org.jdom.Element; + +/** + * JDom implementation of poms PLUGIN element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomPlugin extends Plugin implements MavenCoordinate +{ + private Element plugin; + private final MavenCoordinate coordinate; + + public JDomPlugin( Element plugin ) + { + this.plugin = plugin; + this.coordinate = new JDomMavenCoordinate( plugin ); + } + + @Override + public void addDependency( Dependency dependency ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void addExecution( PluginExecution pluginExecution ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getArtifactId() + { + return coordinate.getArtifactId(); + } + + @Override + public List getDependencies() + { + Element dependenciesElm = plugin.getChild( "dependencies", plugin.getNamespace() ); + if ( dependenciesElm == null ) + { + return Collections.emptyList(); + } + else + { + List dependencyElms = + dependenciesElm.getChildren( "dependency", plugin.getNamespace() ); + + List dependencies = new ArrayList<>( dependencyElms.size() ); + + for ( Element dependencyElm : dependencyElms ) + { + dependencies.add( new JDomDependency( dependencyElm ) ); + } + + return dependencies; + } + } + + @Override + public List getExecutions() + { + throw new UnsupportedOperationException(); + } + + @Override + public Object getGoals() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getGroupId() + { + return coordinate.getGroupId(); + } + + @Override + public String getVersion() + { + return coordinate.getVersion(); + } + + @Override + public boolean isExtensions() + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeDependency( Dependency dependency ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void removeExecution( PluginExecution pluginExecution ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setArtifactId( String artifactId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setDependencies( List dependencies ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExecutions( List executions ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExtensions( boolean extensions ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGoals( Object goals ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGroupId( String groupId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setVersion( String version ) + { + coordinate.setVersion( version ); + } + + @Override + public void flushExecutionMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public Map getExecutionsAsMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getName() + { + return "plugin"; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPluginManagement.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPluginManagement.java index 53e9331e5..b997bde20 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPluginManagement.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomPluginManagement.java @@ -1,98 +1,98 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginManagement; -import org.jdom.Element; - -/** - * JDom implementation of poms PLUGINMANAGEMENT element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomPluginManagement extends PluginManagement -{ - private final Element pluginManagement; - - public JDomPluginManagement( Element pluginManagement ) - { - this.pluginManagement = pluginManagement; - } - - @Override - public void addPlugin( Plugin plugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public List getPlugins() - { - Element pluginsElm = pluginManagement.getChild( "plugins", pluginManagement.getNamespace() ); - if ( pluginsElm == null ) - { - return Collections.emptyList(); - } - else - { - List pluginElms = pluginsElm.getChildren( "plugin", pluginManagement.getNamespace() ); - - List plugins = new ArrayList<>( pluginElms.size() ); - - for ( Element pluginElm : pluginElms ) - { - plugins.add( new JDomPlugin( pluginElm ) ); - } - - return plugins; - } - } - - @Override - public void removePlugin( Plugin plugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setPlugins( List plugins ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void flushPluginMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public Map getPluginsAsMap() - { - throw new UnsupportedOperationException(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.Plugin; +import org.apache.maven.model.PluginManagement; +import org.jdom.Element; + +/** + * JDom implementation of poms PLUGINMANAGEMENT element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomPluginManagement extends PluginManagement +{ + private final Element pluginManagement; + + public JDomPluginManagement( Element pluginManagement ) + { + this.pluginManagement = pluginManagement; + } + + @Override + public void addPlugin( Plugin plugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public List getPlugins() + { + Element pluginsElm = pluginManagement.getChild( "plugins", pluginManagement.getNamespace() ); + if ( pluginsElm == null ) + { + return Collections.emptyList(); + } + else + { + List pluginElms = pluginsElm.getChildren( "plugin", pluginManagement.getNamespace() ); + + List plugins = new ArrayList<>( pluginElms.size() ); + + for ( Element pluginElm : pluginElms ) + { + plugins.add( new JDomPlugin( pluginElm ) ); + } + + return plugins; + } + } + + @Override + public void removePlugin( Plugin plugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setPlugins( List plugins ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void flushPluginMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public Map getPluginsAsMap() + { + throw new UnsupportedOperationException(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProfile.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProfile.java index 25199b537..0bcc4bb70 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProfile.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProfile.java @@ -1,63 +1,63 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.List; - -import org.apache.maven.model.BuildBase; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.DependencyManagement; -import org.apache.maven.model.Profile; -import org.jdom.Element; - -/** - * JDom implementation of poms PROFILE element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomProfile - extends Profile -{ - private final JDomModelBase modelBase; - - public JDomProfile( Element profile ) - { - this.modelBase = new JDomModelBase( profile ) ; - } - - @Override - public BuildBase getBuild() - { - return modelBase.getBuild(); - } - - @Override - public List getDependencies() - { - return modelBase.getDependencies(); - } - - @Override - public DependencyManagement getDependencyManagement() - { - return modelBase.getDependencyManagement(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.List; + +import org.apache.maven.model.BuildBase; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.Profile; +import org.jdom.Element; + +/** + * JDom implementation of poms PROFILE element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomProfile + extends Profile +{ + private final JDomModelBase modelBase; + + public JDomProfile( Element profile ) + { + this.modelBase = new JDomModelBase( profile ) ; + } + + @Override + public BuildBase getBuild() + { + return modelBase.getBuild(); + } + + @Override + public List getDependencies() + { + return modelBase.getDependencies(); + } + + @Override + public DependencyManagement getDependencyManagement() + { + return modelBase.getDependencyManagement(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProperties.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProperties.java index 81aff54e4..a0f4c75c9 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProperties.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomProperties.java @@ -1,161 +1,161 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.Writer; -import java.util.Enumeration; -import java.util.InvalidPropertiesFormatException; -import java.util.Properties; -import java.util.Set; - -import org.jdom.Element; - -/** - * JDom implementation of poms PROPERTIES element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomProperties extends Properties -{ - private final Element properties; - - public JDomProperties( Element properties ) - { - this.properties = properties; - } - - @Override - public synchronized Object setProperty( String key, String value ) - { - Element property = properties.getChild( key, properties.getNamespace() ); - - JDomUtils.rewriteValue( property, value ); - - // todo follow specs of Hashtable.put - return null; - } - - @Override - public synchronized void load( Reader reader ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public synchronized void load( InputStream inStream ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public void save( OutputStream out, String comments ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void store( Writer writer, String comments ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public void store( OutputStream out, String comments ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public synchronized void loadFromXML( InputStream in ) - throws IOException, InvalidPropertiesFormatException - { - throw new UnsupportedOperationException(); - } - - @Override - public void storeToXML( OutputStream os, String comment ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public void storeToXML( OutputStream os, String comment, String encoding ) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public String getProperty( String key ) - { - Element property = properties.getChild( key, properties.getNamespace() ); - - if ( property == null ) - { - return null; - } - else - { - return property.getTextTrim(); - } - } - - @Override - public String getProperty( String key, String defaultValue ) - { - throw new UnsupportedOperationException(); - } - - @Override - public Enumeration propertyNames() - { - throw new UnsupportedOperationException(); - } - - @Override - public Set stringPropertyNames() - { - throw new UnsupportedOperationException(); - } - - @Override - public void list( PrintStream out ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void list( PrintWriter out ) - { - throw new UnsupportedOperationException(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.util.Enumeration; +import java.util.InvalidPropertiesFormatException; +import java.util.Properties; +import java.util.Set; + +import org.jdom.Element; + +/** + * JDom implementation of poms PROPERTIES element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomProperties extends Properties +{ + private final Element properties; + + public JDomProperties( Element properties ) + { + this.properties = properties; + } + + @Override + public synchronized Object setProperty( String key, String value ) + { + Element property = properties.getChild( key, properties.getNamespace() ); + + JDomUtils.rewriteValue( property, value ); + + // todo follow specs of Hashtable.put + return null; + } + + @Override + public synchronized void load( Reader reader ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized void load( InputStream inStream ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public void save( OutputStream out, String comments ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void store( Writer writer, String comments ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public void store( OutputStream out, String comments ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public synchronized void loadFromXML( InputStream in ) + throws IOException, InvalidPropertiesFormatException + { + throw new UnsupportedOperationException(); + } + + @Override + public void storeToXML( OutputStream os, String comment ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public void storeToXML( OutputStream os, String comment, String encoding ) + throws IOException + { + throw new UnsupportedOperationException(); + } + + @Override + public String getProperty( String key ) + { + Element property = properties.getChild( key, properties.getNamespace() ); + + if ( property == null ) + { + return null; + } + else + { + return property.getTextTrim(); + } + } + + @Override + public String getProperty( String key, String defaultValue ) + { + throw new UnsupportedOperationException(); + } + + @Override + public Enumeration propertyNames() + { + throw new UnsupportedOperationException(); + } + + @Override + public Set stringPropertyNames() + { + throw new UnsupportedOperationException(); + } + + @Override + public void list( PrintStream out ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void list( PrintWriter out ) + { + throw new UnsupportedOperationException(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReportPlugin.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReportPlugin.java index 40a82b75b..b781ef116 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReportPlugin.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReportPlugin.java @@ -1,165 +1,165 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.List; -import java.util.Map; - -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.ReportSet; -import org.apache.maven.shared.release.transform.MavenCoordinate; -import org.jdom.Element; - -/** - * JDom implementation of poms reports PLUGIN element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomReportPlugin - extends ReportPlugin implements MavenCoordinate -{ - private final MavenCoordinate coordinate; - - public JDomReportPlugin( Element reportPlugin ) - { - this.coordinate = new JDomMavenCoordinate( reportPlugin ); - } - - @Override - public void addReportSet( ReportSet reportSet ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getArtifactId() - { - return coordinate.getArtifactId(); - } - - @Override - public Object getConfiguration() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getGroupId() - { - return coordinate.getGroupId(); - } - - @Override - public String getInherited() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getReportSets() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getVersion() - { - return coordinate.getVersion(); - } - - @Override - public void removeReportSet( ReportSet reportSet ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setArtifactId( String artifactId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setConfiguration( Object configuration ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setGroupId( String groupId ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setInherited( String inherited ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setReportSets( List reportSets ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setVersion( String version ) - { - coordinate.setVersion( version ); - } - - @Override - public void flushReportSetMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public Map getReportSetsAsMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getKey() - { - throw new UnsupportedOperationException(); - } - - @Override - public void unsetInheritanceApplied() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isInheritanceApplied() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getName() - { - return "plugin"; - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.List; +import java.util.Map; + +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.ReportSet; +import org.apache.maven.shared.release.transform.MavenCoordinate; +import org.jdom.Element; + +/** + * JDom implementation of poms reports PLUGIN element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomReportPlugin + extends ReportPlugin implements MavenCoordinate +{ + private final MavenCoordinate coordinate; + + public JDomReportPlugin( Element reportPlugin ) + { + this.coordinate = new JDomMavenCoordinate( reportPlugin ); + } + + @Override + public void addReportSet( ReportSet reportSet ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getArtifactId() + { + return coordinate.getArtifactId(); + } + + @Override + public Object getConfiguration() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getGroupId() + { + return coordinate.getGroupId(); + } + + @Override + public String getInherited() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getReportSets() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getVersion() + { + return coordinate.getVersion(); + } + + @Override + public void removeReportSet( ReportSet reportSet ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setArtifactId( String artifactId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setConfiguration( Object configuration ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setGroupId( String groupId ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setInherited( String inherited ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setReportSets( List reportSets ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setVersion( String version ) + { + coordinate.setVersion( version ); + } + + @Override + public void flushReportSetMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public Map getReportSetsAsMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getKey() + { + throw new UnsupportedOperationException(); + } + + @Override + public void unsetInheritanceApplied() + { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isInheritanceApplied() + { + throw new UnsupportedOperationException(); + } + + @Override + public String getName() + { + return "plugin"; + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReporting.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReporting.java index 88963033b..2a07f15a1 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReporting.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomReporting.java @@ -1,123 +1,123 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.Reporting; -import org.jdom.Element; - -/** - * JDom implementation of poms REPORTING element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomReporting extends Reporting -{ - - private final Element reporting; - - public JDomReporting( Element reporting ) - { - this.reporting = reporting; - } - - @Override - public void addPlugin( ReportPlugin reportPlugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public String getOutputDirectory() - { - throw new UnsupportedOperationException(); - } - - @Override - public List getPlugins() - { - Element pluginsElm = reporting.getChild( "plugins", reporting.getNamespace() ); - if ( pluginsElm == null ) - { - return Collections.emptyList(); - } - else - { - List pluginElms = pluginsElm.getChildren( "plugin", reporting.getNamespace() ); - - List plugins = new ArrayList<>( pluginElms.size() ); - - for ( Element pluginElm : pluginElms ) - { - plugins.add( new JDomReportPlugin( pluginElm ) ); - } - - return plugins; - } - } - - @Override - public void removePlugin( ReportPlugin reportPlugin ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setOutputDirectory( String outputDirectory ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void setPlugins( List plugins ) - { - throw new UnsupportedOperationException(); - } - - @Override - public void flushReportPluginMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public Map getReportPluginsAsMap() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isExcludeDefaults() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setExcludeDefaults( boolean excludeDefaults ) - { - throw new UnsupportedOperationException(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.model.ReportPlugin; +import org.apache.maven.model.Reporting; +import org.jdom.Element; + +/** + * JDom implementation of poms REPORTING element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomReporting extends Reporting +{ + + private final Element reporting; + + public JDomReporting( Element reporting ) + { + this.reporting = reporting; + } + + @Override + public void addPlugin( ReportPlugin reportPlugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public String getOutputDirectory() + { + throw new UnsupportedOperationException(); + } + + @Override + public List getPlugins() + { + Element pluginsElm = reporting.getChild( "plugins", reporting.getNamespace() ); + if ( pluginsElm == null ) + { + return Collections.emptyList(); + } + else + { + List pluginElms = pluginsElm.getChildren( "plugin", reporting.getNamespace() ); + + List plugins = new ArrayList<>( pluginElms.size() ); + + for ( Element pluginElm : pluginElms ) + { + plugins.add( new JDomReportPlugin( pluginElm ) ); + } + + return plugins; + } + } + + @Override + public void removePlugin( ReportPlugin reportPlugin ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setOutputDirectory( String outputDirectory ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void setPlugins( List plugins ) + { + throw new UnsupportedOperationException(); + } + + @Override + public void flushReportPluginMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public Map getReportPluginsAsMap() + { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isExcludeDefaults() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setExcludeDefaults( boolean excludeDefaults ) + { + throw new UnsupportedOperationException(); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomScm.java index 863ec1b32..9187dcc2d 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomScm.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomScm.java @@ -1,87 +1,87 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.model.Scm; -import org.jdom.Element; - -/** - * JDom implementation of poms SCM element - * - * @author Robert Scholte - * @since 3.0 - */ -public class JDomScm extends Scm -{ - private Element scm; - - JDomScm( Element scm ) - { - this.scm = scm; - } - - @Override - public String getConnection() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setConnection( String connection ) - { - JDomUtils.rewriteElement( "connection", connection, scm, scm.getNamespace() ); - } - - @Override - public String getDeveloperConnection() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setDeveloperConnection( String developerConnection ) - { - JDomUtils.rewriteElement( "developerConnection", developerConnection, scm, scm.getNamespace() ); - } - - @Override - public String getTag() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setTag( String tag ) - { - JDomUtils.rewriteElement( "tag", tag, scm, scm.getNamespace() ); - } - - @Override - public String getUrl() - { - throw new UnsupportedOperationException(); - } - - @Override - public void setUrl( String url ) - { - JDomUtils.rewriteElement( "url", url, scm, scm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.model.Scm; +import org.jdom.Element; + +/** + * JDom implementation of poms SCM element + * + * @author Robert Scholte + * @since 3.0 + */ +public class JDomScm extends Scm +{ + private Element scm; + + JDomScm( Element scm ) + { + this.scm = scm; + } + + @Override + public String getConnection() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setConnection( String connection ) + { + JDomUtils.rewriteElement( "connection", connection, scm, scm.getNamespace() ); + } + + @Override + public String getDeveloperConnection() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setDeveloperConnection( String developerConnection ) + { + JDomUtils.rewriteElement( "developerConnection", developerConnection, scm, scm.getNamespace() ); + } + + @Override + public String getTag() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setTag( String tag ) + { + JDomUtils.rewriteElement( "tag", tag, scm, scm.getNamespace() ); + } + + @Override + public String getUrl() + { + throw new UnsupportedOperationException(); + } + + @Override + public void setUrl( String url ) + { + JDomUtils.rewriteElement( "url", url, scm, scm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomUtils.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomUtils.java index abe608785..17355f87b 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomUtils.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom/JDomUtils.java @@ -1,132 +1,132 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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.util.Iterator; - -import org.jdom.Element; -import org.jdom.Namespace; -import org.jdom.Text; - -/** - * Common JDom functions - * - * @author Robert Scholte - * @since 3.0 - */ -public final class JDomUtils -{ - - private JDomUtils() - { - // noop - } - - /** - * Updates the text value of the given element. The primary purpose of this method is to preserve any whitespace and - * comments around the original text value. - * - * @param element The element to update, must not be null. - * @param value The text string to set, must not be null. - */ - public static void rewriteValue( Element element, String value ) - { - Text text = null; - if ( element.getContent() != null ) - { - for ( Iterator it = element.getContent().iterator(); it.hasNext(); ) - { - Object content = it.next(); - if ( ( content instanceof Text ) && ( (Text) content ).getTextTrim().length() > 0 ) - { - text = (Text) content; - while ( it.hasNext() ) - { - content = it.next(); - if ( content instanceof Text ) - { - text.append( (Text) content ); - it.remove(); - } - else - { - break; - } - } - break; - } - } - } - if ( text == null ) - { - element.addContent( value ); - } - else - { - String chars = text.getText(); - String trimmed = text.getTextTrim(); - int idx = chars.indexOf( trimmed ); - String leadingWhitespace = chars.substring( 0, idx ); - String trailingWhitespace = chars.substring( idx + trimmed.length() ); - text.setText( leadingWhitespace + value + trailingWhitespace ); - } - } - - public static Element rewriteElement( String name, String value, Element root, Namespace namespace ) - { - Element tagElement = root.getChild( name, namespace ); - if ( tagElement != null ) - { - if ( value != null ) - { - rewriteValue( tagElement, value ); - } - else - { - int index = root.indexOf( tagElement ); - root.removeContent( index ); - for ( int i = index - 1; i >= 0; i-- ) - { - if ( root.getContent( i ) instanceof Text ) - { - root.removeContent( i ); - } - else - { - break; - } - } - } - } - else - { - if ( value != null ) - { - Element element = new Element( name, namespace ); - element.setText( value ); - root.addContent( " " ).addContent( element ).addContent( "\n " ); - tagElement = element; - } - } - return tagElement; - } - - -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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.util.Iterator; + +import org.jdom.Element; +import org.jdom.Namespace; +import org.jdom.Text; + +/** + * Common JDom functions + * + * @author Robert Scholte + * @since 3.0 + */ +public final class JDomUtils +{ + + private JDomUtils() + { + // noop + } + + /** + * Updates the text value of the given element. The primary purpose of this method is to preserve any whitespace and + * comments around the original text value. + * + * @param element The element to update, must not be null. + * @param value The text string to set, must not be null. + */ + public static void rewriteValue( Element element, String value ) + { + Text text = null; + if ( element.getContent() != null ) + { + for ( Iterator it = element.getContent().iterator(); it.hasNext(); ) + { + Object content = it.next(); + if ( ( content instanceof Text ) && ( (Text) content ).getTextTrim().length() > 0 ) + { + text = (Text) content; + while ( it.hasNext() ) + { + content = it.next(); + if ( content instanceof Text ) + { + text.append( (Text) content ); + it.remove(); + } + else + { + break; + } + } + break; + } + } + } + if ( text == null ) + { + element.addContent( value ); + } + else + { + String chars = text.getText(); + String trimmed = text.getTextTrim(); + int idx = chars.indexOf( trimmed ); + String leadingWhitespace = chars.substring( 0, idx ); + String trailingWhitespace = chars.substring( idx + trimmed.length() ); + text.setText( leadingWhitespace + value + trailingWhitespace ); + } + } + + public static Element rewriteElement( String name, String value, Element root, Namespace namespace ) + { + Element tagElement = root.getChild( name, namespace ); + if ( tagElement != null ) + { + if ( value != null ) + { + rewriteValue( tagElement, value ); + } + else + { + int index = root.indexOf( tagElement ); + root.removeContent( index ); + for ( int i = index - 1; i >= 0; i-- ) + { + if ( root.getContent( i ) instanceof Text ) + { + root.removeContent( i ); + } + else + { + break; + } + } + } + } + else + { + if ( value != null ) + { + Element element = new Element( name, namespace ); + element.setText( value ); + root.addContent( " " ).addContent( element ).addContent( "\n " ); + tagElement = element; + } + } + return tagElement; + } + + +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java index 633a19f07..9b491cc29 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/PlexusJUnit4TestCase.java @@ -1,291 +1,291 @@ -package org.apache.maven.shared.release; - -/* - * 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 static org.junit.Assert.fail; - -import java.io.File; -import java.io.InputStream; - -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusContainerException; -import org.codehaus.plexus.configuration.PlexusConfiguration; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.DefaultContext; -import org.junit.After; -import org.junit.Before; - -/** - * Based on PlexusTestCase from org.sonatype.sisu:sisu-inject-plexus - * - * @author Robert Scholte - */ -public abstract class PlexusJUnit4TestCase -{ - private PlexusContainer container; - - private static String basedir; - - @Before - public void setUp() - throws Exception - { - basedir = getBasedir(); - } - - protected void setupContainer() - { - // ---------------------------------------------------------------------------- - // Context Setup - // ---------------------------------------------------------------------------- - - final DefaultContext context = new DefaultContext(); - - context.put( "basedir", getBasedir() ); - - customizeContext( context ); - - final boolean hasPlexusHome = context.contains( "plexus.home" ); - - if ( !hasPlexusHome ) - { - final File f = getTestFile( "target/plexus-home" ); - - if ( !f.isDirectory() ) - { - f.mkdir(); - } - - context.put( "plexus.home", f.getAbsolutePath() ); - } - - // ---------------------------------------------------------------------------- - // Configuration - // ---------------------------------------------------------------------------- - - final String config = getCustomConfigurationName(); - - final ContainerConfiguration containerConfiguration = - new DefaultContainerConfiguration().setName( "test" ).setContext( context.getContextData() ).setClassPathCaching( true ); - - if ( config != null ) - { - containerConfiguration.setContainerConfiguration( config ); - } - else - { - final String resource = getConfigurationName( null ); - - containerConfiguration.setContainerConfiguration( resource ); - } - - customizeContainerConfiguration( containerConfiguration ); - - try - { - container = new DefaultPlexusContainer( containerConfiguration ); - } - catch ( final PlexusContainerException e ) - { - e.printStackTrace(); - fail( "Failed to create plexus container." ); - } - } - - /** - * Allow custom test case implementations do augment the default container configuration before executing tests. - * - * @param containerConfiguration - */ - protected void customizeContainerConfiguration( final ContainerConfiguration containerConfiguration ) - { - } - - protected void customizeContext( final Context context ) - { - } - - protected PlexusConfiguration customizeComponentConfiguration() - { - return null; - } - - @After - public void tearDown() - throws Exception - { - if ( container != null ) - { - container.dispose(); - - container = null; - } - } - - protected PlexusContainer getContainer() - { - if ( container == null ) - { - setupContainer(); - } - - return container; - } - - protected InputStream getConfiguration() - throws Exception - { - return getConfiguration( null ); - } - - @SuppressWarnings( "unused" ) - protected InputStream getConfiguration( final String subname ) - throws Exception - { - return getResourceAsStream( getConfigurationName( subname ) ); - } - - protected String getCustomConfigurationName() - { - return null; - } - - /** - * Allow the retrieval of a container configuration that is based on the name of the test class being run. So if you - * have a test class called org.foo.FunTest, then this will produce a resource name of org/foo/FunTest.xml which - * would be used to configure the Plexus container before running your test. - * - * @param subname - * @return - */ - protected String getConfigurationName( final String subname ) - { - return getClass().getName().replace( '.', '/' ) + ".xml"; - } - - protected InputStream getResourceAsStream( final String resource ) - { - return getClass().getResourceAsStream( resource ); - } - - protected ClassLoader getClassLoader() - { - return getClass().getClassLoader(); - } - - // ---------------------------------------------------------------------- - // Container access - // ---------------------------------------------------------------------- - - protected Object lookup( final String componentKey ) - throws Exception - { - return getContainer().lookup( componentKey ); - } - - protected Object lookup( final String role, final String roleHint ) - throws Exception - { - return getContainer().lookup( role, roleHint ); - } - - protected T lookup( final Class componentClass ) - throws Exception - { - return getContainer().lookup( componentClass ); - } - - protected T lookup( final Class componentClass, final String roleHint ) - throws Exception - { - return getContainer().lookup( componentClass, roleHint ); - } - - protected void release( final Object component ) - throws Exception - { - getContainer().release( component ); - } - - // ---------------------------------------------------------------------- - // Helper methods for sub classes - // ---------------------------------------------------------------------- - - public static File getTestFile( final String path ) - { - return new File( getBasedir(), path ); - } - - @SuppressWarnings( "hiding" ) - public static File getTestFile( final String basedir, final String path ) - { - File basedirFile = new File( basedir ); - - if ( !basedirFile.isAbsolute() ) - { - basedirFile = getTestFile( basedir ); - } - - return new File( basedirFile, path ); - } - - public static String getTestPath( final String path ) - { - return getTestFile( path ).getAbsolutePath(); - } - - @SuppressWarnings( "hiding" ) - public static String getTestPath( final String basedir, final String path ) - { - return getTestFile( basedir, path ).getAbsolutePath(); - } - - public static String getBasedir() - { - if ( basedir != null ) - { - return basedir; - } - - basedir = System.getProperty( "basedir" ); - - if ( basedir == null ) - { - basedir = new File( "" ).getAbsolutePath(); - } - - return basedir; - } - - public String getTestConfiguration() - { - return getTestConfiguration( getClass() ); - } - - public static String getTestConfiguration( final Class clazz ) - { - final String s = clazz.getName().replace( '.', '/' ); - - return s.substring( 0, s.indexOf( "$" ) ) + ".xml"; - } -} +package org.apache.maven.shared.release; + +/* + * 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 static org.junit.Assert.fail; + +import java.io.File; +import java.io.InputStream; + +import org.codehaus.plexus.ContainerConfiguration; +import org.codehaus.plexus.DefaultContainerConfiguration; +import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.PlexusContainerException; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.DefaultContext; +import org.junit.After; +import org.junit.Before; + +/** + * Based on PlexusTestCase from org.sonatype.sisu:sisu-inject-plexus + * + * @author Robert Scholte + */ +public abstract class PlexusJUnit4TestCase +{ + private PlexusContainer container; + + private static String basedir; + + @Before + public void setUp() + throws Exception + { + basedir = getBasedir(); + } + + protected void setupContainer() + { + // ---------------------------------------------------------------------------- + // Context Setup + // ---------------------------------------------------------------------------- + + final DefaultContext context = new DefaultContext(); + + context.put( "basedir", getBasedir() ); + + customizeContext( context ); + + final boolean hasPlexusHome = context.contains( "plexus.home" ); + + if ( !hasPlexusHome ) + { + final File f = getTestFile( "target/plexus-home" ); + + if ( !f.isDirectory() ) + { + f.mkdir(); + } + + context.put( "plexus.home", f.getAbsolutePath() ); + } + + // ---------------------------------------------------------------------------- + // Configuration + // ---------------------------------------------------------------------------- + + final String config = getCustomConfigurationName(); + + final ContainerConfiguration containerConfiguration = + new DefaultContainerConfiguration().setName( "test" ).setContext( context.getContextData() ).setClassPathCaching( true ); + + if ( config != null ) + { + containerConfiguration.setContainerConfiguration( config ); + } + else + { + final String resource = getConfigurationName( null ); + + containerConfiguration.setContainerConfiguration( resource ); + } + + customizeContainerConfiguration( containerConfiguration ); + + try + { + container = new DefaultPlexusContainer( containerConfiguration ); + } + catch ( final PlexusContainerException e ) + { + e.printStackTrace(); + fail( "Failed to create plexus container." ); + } + } + + /** + * Allow custom test case implementations do augment the default container configuration before executing tests. + * + * @param containerConfiguration + */ + protected void customizeContainerConfiguration( final ContainerConfiguration containerConfiguration ) + { + } + + protected void customizeContext( final Context context ) + { + } + + protected PlexusConfiguration customizeComponentConfiguration() + { + return null; + } + + @After + public void tearDown() + throws Exception + { + if ( container != null ) + { + container.dispose(); + + container = null; + } + } + + protected PlexusContainer getContainer() + { + if ( container == null ) + { + setupContainer(); + } + + return container; + } + + protected InputStream getConfiguration() + throws Exception + { + return getConfiguration( null ); + } + + @SuppressWarnings( "unused" ) + protected InputStream getConfiguration( final String subname ) + throws Exception + { + return getResourceAsStream( getConfigurationName( subname ) ); + } + + protected String getCustomConfigurationName() + { + return null; + } + + /** + * Allow the retrieval of a container configuration that is based on the name of the test class being run. So if you + * have a test class called org.foo.FunTest, then this will produce a resource name of org/foo/FunTest.xml which + * would be used to configure the Plexus container before running your test. + * + * @param subname + * @return + */ + protected String getConfigurationName( final String subname ) + { + return getClass().getName().replace( '.', '/' ) + ".xml"; + } + + protected InputStream getResourceAsStream( final String resource ) + { + return getClass().getResourceAsStream( resource ); + } + + protected ClassLoader getClassLoader() + { + return getClass().getClassLoader(); + } + + // ---------------------------------------------------------------------- + // Container access + // ---------------------------------------------------------------------- + + protected Object lookup( final String componentKey ) + throws Exception + { + return getContainer().lookup( componentKey ); + } + + protected Object lookup( final String role, final String roleHint ) + throws Exception + { + return getContainer().lookup( role, roleHint ); + } + + protected T lookup( final Class componentClass ) + throws Exception + { + return getContainer().lookup( componentClass ); + } + + protected T lookup( final Class componentClass, final String roleHint ) + throws Exception + { + return getContainer().lookup( componentClass, roleHint ); + } + + protected void release( final Object component ) + throws Exception + { + getContainer().release( component ); + } + + // ---------------------------------------------------------------------- + // Helper methods for sub classes + // ---------------------------------------------------------------------- + + public static File getTestFile( final String path ) + { + return new File( getBasedir(), path ); + } + + @SuppressWarnings( "hiding" ) + public static File getTestFile( final String basedir, final String path ) + { + File basedirFile = new File( basedir ); + + if ( !basedirFile.isAbsolute() ) + { + basedirFile = getTestFile( basedir ); + } + + return new File( basedirFile, path ); + } + + public static String getTestPath( final String path ) + { + return getTestFile( path ).getAbsolutePath(); + } + + @SuppressWarnings( "hiding" ) + public static String getTestPath( final String basedir, final String path ) + { + return getTestFile( basedir, path ).getAbsolutePath(); + } + + public static String getBasedir() + { + if ( basedir != null ) + { + return basedir; + } + + basedir = System.getProperty( "basedir" ); + + if ( basedir == null ) + { + basedir = new File( "" ).getAbsolutePath(); + } + + return basedir; + } + + public String getTestConfiguration() + { + return getTestConfiguration( getClass() ); + } + + public static String getTestConfiguration( final Class clazz ) + { + final String s = clazz.getName().replace( '.', '/' ); + + return s.substring( 0, s.indexOf( "$" ) ) + ".xml"; + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java index 3633e3aab..e4dab0ca9 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/RemoveScmTagPhaseTest.java @@ -1,246 +1,246 @@ -package org.apache.maven.shared.release.phase; - -/* - * 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.util.List; - -import org.apache.maven.project.MavenProject; -import org.apache.maven.scm.CommandParameters; -import org.apache.maven.scm.ScmFileSet; -import org.apache.maven.scm.command.untag.UntagScmResult; -import org.apache.maven.scm.manager.ScmManager; -import org.apache.maven.scm.provider.ScmProvider; -import org.apache.maven.scm.repository.ScmRepository; -import org.apache.maven.shared.release.ReleaseResult; -import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; -import org.apache.maven.shared.release.config.ReleaseUtils; -import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; -import org.apache.maven.shared.release.scm.ReleaseScmCommandException; -import org.apache.maven.shared.release.stubs.ScmManagerStub; -import org.apache.maven.shared.release.util.ReleaseUtil; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.Matchers; -import org.mockito.Mockito; - -/** - * Test the remove SCM tag phase. - */ -public class RemoveScmTagPhaseTest extends AbstractReleaseTestCase -{ - - @Override - public void setUp() throws Exception - { - - super.setUp(); - - phase = ( ReleasePhase ) lookup( ReleasePhase.class, "remove-scm-tag" ); - - } - - @Test - public void testExecuteOutput() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - - // mock, only real matcher is the file set - ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); - Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), - Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), - Matchers.isA( CommandParameters.class ) ) ) - .thenReturn( new UntagScmResult( "...", "...", "...", true ) ); - ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); - stub.setScmProvider( scmProviderMock ); - - // execute - ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - // verify, actual contains trailing newline - Assert.assertEquals( "[INFO] Removing tag with the label release-label ...", actual.getOutput().trim() ); - - } - - @Test - public void testExecuteResultCode() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - - // mock, only real matcher is the file set - ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); - Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), - Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), - Matchers.isA( CommandParameters.class ) ) ) - .thenReturn( new UntagScmResult( "...", "...", "...", true ) ); - ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); - stub.setScmProvider( scmProviderMock ); - - // execute - ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - // verify - Assert.assertEquals( 0, actual.getResultCode() ); - - } - - @Rule - public ExpectedException exceptionRule = ExpectedException.none(); - - @Test - @Ignore( "We changed the behaviour to warning instead of error." ) - public void testExecuteError() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - - // mock, only real matcher is the file set - ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); - Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), - Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), - Matchers.isA( CommandParameters.class ) ) ) - .thenReturn( new UntagScmResult( "command-line", "provider-message", "command-output", false ) ); - ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); - stub.setScmProvider( scmProviderMock ); - - // set up exception rule - exceptionRule.expect( ReleaseScmCommandException.class ); - exceptionRule.expectMessage( - "Unable to remove tag \nProvider message:\nprovider-message\nCommand output:\ncommand-output" ); - - // execute - phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - } - - @Test - public void testExecuteNoError() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); - - // mock, only real matcher is the file set - ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); - Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), - Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), - Matchers.isA( CommandParameters.class ) ) ) - .thenReturn( new UntagScmResult( "command-line", "provider-message", "command-output", false ) ); - ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); - stub.setScmProvider( scmProviderMock ); - - // execute - ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - // verify - Assert.assertEquals( 0, actual.getResultCode() ); - - - } - - @Test - public void testSimulateOutput() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - - // execute - ReleaseResult actual = phase.simulate(ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - // verify, actual contains newline - Assert.assertEquals( "[INFO] Full run would remove tag with label: 'release-label'", - actual.getOutput().trim() ); - - } - - @Test - public void testSimulateResultCode() throws Exception - { - - // prepare - ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); - builder.setScmReleaseLabel( "release-label" ); - builder.setScmSourceUrl( "scm-url" ); - List reactorProjects = createReactorProjects(); - MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); - builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); - builder.setPomFileName( rootProject.getFile().getName() ); - - // execute - ReleaseResult actual = phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), - new DefaultReleaseEnvironment(), reactorProjects ); - - Assert.assertEquals( 0, actual.getResultCode() ); - - } - - private List createReactorProjects() throws Exception - { - return createReactorProjects( "scm-commit/single-pom", "" ); - } - -} +package org.apache.maven.shared.release.phase; + +/* + * 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.util.List; + +import org.apache.maven.project.MavenProject; +import org.apache.maven.scm.CommandParameters; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.command.untag.UntagScmResult; +import org.apache.maven.scm.manager.ScmManager; +import org.apache.maven.scm.provider.ScmProvider; +import org.apache.maven.scm.repository.ScmRepository; +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder; +import org.apache.maven.shared.release.config.ReleaseUtils; +import org.apache.maven.shared.release.env.DefaultReleaseEnvironment; +import org.apache.maven.shared.release.scm.ReleaseScmCommandException; +import org.apache.maven.shared.release.stubs.ScmManagerStub; +import org.apache.maven.shared.release.util.ReleaseUtil; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Matchers; +import org.mockito.Mockito; + +/** + * Test the remove SCM tag phase. + */ +public class RemoveScmTagPhaseTest extends AbstractReleaseTestCase +{ + + @Override + public void setUp() throws Exception + { + + super.setUp(); + + phase = ( ReleasePhase ) lookup( ReleasePhase.class, "remove-scm-tag" ); + + } + + @Test + public void testExecuteOutput() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); + + // mock, only real matcher is the file set + ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); + Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), + Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), + Matchers.isA( CommandParameters.class ) ) ) + .thenReturn( new UntagScmResult( "...", "...", "...", true ) ); + ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); + stub.setScmProvider( scmProviderMock ); + + // execute + ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + // verify, actual contains trailing newline + Assert.assertEquals( "[INFO] Removing tag with the label release-label ...", actual.getOutput().trim() ); + + } + + @Test + public void testExecuteResultCode() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); + + // mock, only real matcher is the file set + ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); + Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), + Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), + Matchers.isA( CommandParameters.class ) ) ) + .thenReturn( new UntagScmResult( "...", "...", "...", true ) ); + ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); + stub.setScmProvider( scmProviderMock ); + + // execute + ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + // verify + Assert.assertEquals( 0, actual.getResultCode() ); + + } + + @Rule + public ExpectedException exceptionRule = ExpectedException.none(); + + @Test + @Ignore( "We changed the behaviour to warning instead of error." ) + public void testExecuteError() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); + + // mock, only real matcher is the file set + ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); + Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), + Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), + Matchers.isA( CommandParameters.class ) ) ) + .thenReturn( new UntagScmResult( "command-line", "provider-message", "command-output", false ) ); + ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); + stub.setScmProvider( scmProviderMock ); + + // set up exception rule + exceptionRule.expect( ReleaseScmCommandException.class ); + exceptionRule.expectMessage( + "Unable to remove tag \nProvider message:\nprovider-message\nCommand output:\ncommand-output" ); + + // execute + phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + } + + @Test + public void testExecuteNoError() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + ScmFileSet fileSet = new ScmFileSet( rootProject.getFile().getParentFile() ); + + // mock, only real matcher is the file set + ScmProvider scmProviderMock = Mockito.mock( ScmProvider.class ); + Mockito.when( scmProviderMock.untag( Matchers.isA( ScmRepository.class ), + Matchers.argThat( new IsScmFileSetEquals( fileSet ) ), + Matchers.isA( CommandParameters.class ) ) ) + .thenReturn( new UntagScmResult( "command-line", "provider-message", "command-output", false ) ); + ScmManagerStub stub = ( ScmManagerStub ) lookup( ScmManager.class ); + stub.setScmProvider( scmProviderMock ); + + // execute + ReleaseResult actual = phase.execute( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + // verify + Assert.assertEquals( 0, actual.getResultCode() ); + + + } + + @Test + public void testSimulateOutput() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + + // execute + ReleaseResult actual = phase.simulate(ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + // verify, actual contains newline + Assert.assertEquals( "[INFO] Full run would remove tag with label: 'release-label'", + actual.getOutput().trim() ); + + } + + @Test + public void testSimulateResultCode() throws Exception + { + + // prepare + ReleaseDescriptorBuilder builder = new ReleaseDescriptorBuilder(); + builder.setScmReleaseLabel( "release-label" ); + builder.setScmSourceUrl( "scm-url" ); + List reactorProjects = createReactorProjects(); + MavenProject rootProject = ReleaseUtil.getRootProject( reactorProjects ); + builder.setWorkingDirectory( getPath( rootProject.getFile().getParentFile() ) ); + builder.setPomFileName( rootProject.getFile().getName() ); + + // execute + ReleaseResult actual = phase.simulate( ReleaseUtils.buildReleaseDescriptor( builder ), + new DefaultReleaseEnvironment(), reactorProjects ); + + Assert.assertEquals( 0, actual.getResultCode() ); + + } + + private List createReactorProjects() throws Exception + { + return createReactorProjects( "scm-commit/single-pom", "" ); + } + +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java index 0a4792273..b0c2b69a6 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/policies/DefaultNamingPolicyTest.java @@ -1,44 +1,44 @@ -package org.apache.maven.shared.release.policies; - -/* - * 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 static org.junit.Assert.assertEquals; - -import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; -import org.junit.Test; - -public class DefaultNamingPolicyTest -{ - private DefaultNamingPolicy policy = new DefaultNamingPolicy(); - - @Test - public void testName() throws Exception - { - assertEquals( "ARTIFACTID-VERSION", - policy.getName( newNamingPolicyRequest( "ARTIFACTID", "VERSION" ) ).getName() ); - assertEquals( "ARTIFACTID-1.0-SNAPSHOT", - policy.getName( newNamingPolicyRequest( "ARTIFACTID", "1.0-SNAPSHOT" ) ).getName() ); - } - - private NamingPolicyRequest newNamingPolicyRequest( String artifactId, String version ) - { - return new NamingPolicyRequest().setArtifactId( artifactId ).setVersion( version ); - } -} +package org.apache.maven.shared.release.policies; + +/* + * 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 static org.junit.Assert.assertEquals; + +import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; +import org.junit.Test; + +public class DefaultNamingPolicyTest +{ + private DefaultNamingPolicy policy = new DefaultNamingPolicy(); + + @Test + public void testName() throws Exception + { + assertEquals( "ARTIFACTID-VERSION", + policy.getName( newNamingPolicyRequest( "ARTIFACTID", "VERSION" ) ).getName() ); + assertEquals( "ARTIFACTID-1.0-SNAPSHOT", + policy.getName( newNamingPolicyRequest( "ARTIFACTID", "1.0-SNAPSHOT" ) ).getName() ); + } + + private NamingPolicyRequest newNamingPolicyRequest( String artifactId, String version ) + { + return new NamingPolicyRequest().setArtifactId( artifactId ).setVersion( version ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomBuildTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomBuildTest.java index fd301fd91..1b5939207 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomBuildTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomBuildTest.java @@ -1,306 +1,306 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.StringReader; - -import org.jdom.Document; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomBuildTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test - public void testGetExtensions() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - assertNotNull( new JDomBuild( document.getRootElement() ).getExtensions() ); - assertEquals( 0, new JDomBuild( document.getRootElement() ).getExtensions().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 0, new JDomBuild( document.getRootElement() ).getExtensions().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 1, new JDomBuild( document.getRootElement() ).getExtensions().size() ); - - } - - @Test - public void testGetPluginManagement() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - assertNull( new JDomBuild( document.getRootElement() ).getPluginManagement() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertNotNull( new JDomBuild( document.getRootElement() ).getPluginManagement() ); - } - - @Test - public void testGetPlugins() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - assertNotNull( new JDomBuild( document.getRootElement() ).getPlugins() ); - assertEquals( 0, new JDomBuild( document.getRootElement() ).getPlugins().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 0, new JDomBuild( document.getRootElement() ).getPlugins().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 1, new JDomBuild( document.getRootElement() ).getPlugins().size() ); - } - - // All other methods throw UnsupportedOperationException - - @Test( expected = UnsupportedOperationException.class ) - public void testFlushPluginMap() - { - new JDomBuild( null ).flushPluginMap(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddExtension() - { - new JDomBuild( null ).addExtension( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetOutputDirectory() - { - new JDomBuild( null ).getOutputDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetScriptSourceDirectory() - { - new JDomBuild( null ).getScriptSourceDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetSourceDirectory() - { - new JDomBuild( null ).getSourceDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetTestOutputDirectory() - { - new JDomBuild( null ).getTestOutputDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetTestSourceDirectory() - { - new JDomBuild( null ).getTestSourceDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveExtension() - { - new JDomBuild( null ).removeExtension( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetExtensions() - { - new JDomBuild( null ).setExtensions( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetOutputDirectory() - { - new JDomBuild( null ).setOutputDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetScriptSourceDirectory() - { - new JDomBuild( null ).setScriptSourceDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetSourceDirectory() - { - new JDomBuild( null ).setSourceDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetTestOutputDirectoryString() - { - new JDomBuild( null ).setTestOutputDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetTestSourceDirectory() - { - new JDomBuild( null ).setTestSourceDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddFilter() - { - new JDomBuild( null ).addFilter( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddResource() - { - new JDomBuild( null ).addResource( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddTestResource() - { - new JDomBuild( null ).addTestResource( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetDefaultGoal() - { - new JDomBuild( null ).getDefaultGoal(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetDirectory() - { - new JDomBuild( null ).getDirectory(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetFilters() - { - new JDomBuild( null ).getFilters(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetFinalName() - { - new JDomBuild( null ).getFinalName(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetResources() - { - new JDomBuild( null ).getResources(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetTestResources() - { - new JDomBuild( null ).getTestResources(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveFilter() - { - new JDomBuild( null ).removeFilter( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveResource() - { - new JDomBuild( null ).removeResource( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveTestResource() - { - new JDomBuild( null ).removeTestResource( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetDefaultGoal() - { - new JDomBuild( null ).setDefaultGoal( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetDirectory() - { - new JDomBuild( null ).setDirectory( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetFilters() - { - new JDomBuild( null ).setFilters( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetFinalName() - { - new JDomBuild( null ).setFinalName( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetResources() - { - new JDomBuild( null ).setResources( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetTestResources() - { - new JDomBuild( null ).setTestResources( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetPluginManagement() - { - new JDomBuild( null ).setPluginManagement( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddPlugin() - { - new JDomBuild( null ).addPlugin( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemovePlugin() - { - new JDomBuild( null ).removePlugin( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetPlugins() - { - new JDomBuild( null ).setPlugins( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetPluginsAsMap() - { - new JDomBuild( null ).getPluginsAsMap(); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.StringReader; + +import org.jdom.Document; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomBuildTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test + public void testGetExtensions() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + assertNotNull( new JDomBuild( document.getRootElement() ).getExtensions() ); + assertEquals( 0, new JDomBuild( document.getRootElement() ).getExtensions().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 0, new JDomBuild( document.getRootElement() ).getExtensions().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 1, new JDomBuild( document.getRootElement() ).getExtensions().size() ); + + } + + @Test + public void testGetPluginManagement() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + assertNull( new JDomBuild( document.getRootElement() ).getPluginManagement() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertNotNull( new JDomBuild( document.getRootElement() ).getPluginManagement() ); + } + + @Test + public void testGetPlugins() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + assertNotNull( new JDomBuild( document.getRootElement() ).getPlugins() ); + assertEquals( 0, new JDomBuild( document.getRootElement() ).getPlugins().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 0, new JDomBuild( document.getRootElement() ).getPlugins().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 1, new JDomBuild( document.getRootElement() ).getPlugins().size() ); + } + + // All other methods throw UnsupportedOperationException + + @Test( expected = UnsupportedOperationException.class ) + public void testFlushPluginMap() + { + new JDomBuild( null ).flushPluginMap(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddExtension() + { + new JDomBuild( null ).addExtension( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetOutputDirectory() + { + new JDomBuild( null ).getOutputDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetScriptSourceDirectory() + { + new JDomBuild( null ).getScriptSourceDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetSourceDirectory() + { + new JDomBuild( null ).getSourceDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetTestOutputDirectory() + { + new JDomBuild( null ).getTestOutputDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetTestSourceDirectory() + { + new JDomBuild( null ).getTestSourceDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveExtension() + { + new JDomBuild( null ).removeExtension( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetExtensions() + { + new JDomBuild( null ).setExtensions( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetOutputDirectory() + { + new JDomBuild( null ).setOutputDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetScriptSourceDirectory() + { + new JDomBuild( null ).setScriptSourceDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetSourceDirectory() + { + new JDomBuild( null ).setSourceDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetTestOutputDirectoryString() + { + new JDomBuild( null ).setTestOutputDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetTestSourceDirectory() + { + new JDomBuild( null ).setTestSourceDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddFilter() + { + new JDomBuild( null ).addFilter( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddResource() + { + new JDomBuild( null ).addResource( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddTestResource() + { + new JDomBuild( null ).addTestResource( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetDefaultGoal() + { + new JDomBuild( null ).getDefaultGoal(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetDirectory() + { + new JDomBuild( null ).getDirectory(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetFilters() + { + new JDomBuild( null ).getFilters(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetFinalName() + { + new JDomBuild( null ).getFinalName(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetResources() + { + new JDomBuild( null ).getResources(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetTestResources() + { + new JDomBuild( null ).getTestResources(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveFilter() + { + new JDomBuild( null ).removeFilter( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveResource() + { + new JDomBuild( null ).removeResource( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveTestResource() + { + new JDomBuild( null ).removeTestResource( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetDefaultGoal() + { + new JDomBuild( null ).setDefaultGoal( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetDirectory() + { + new JDomBuild( null ).setDirectory( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetFilters() + { + new JDomBuild( null ).setFilters( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetFinalName() + { + new JDomBuild( null ).setFinalName( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetResources() + { + new JDomBuild( null ).setResources( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetTestResources() + { + new JDomBuild( null ).setTestResources( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetPluginManagement() + { + new JDomBuild( null ).setPluginManagement( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddPlugin() + { + new JDomBuild( null ).addPlugin( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemovePlugin() + { + new JDomBuild( null ).removePlugin( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetPlugins() + { + new JDomBuild( null ).setPlugins( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetPluginsAsMap() + { + new JDomBuild( null ).getPluginsAsMap(); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagementTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagementTest.java index 3af1068c4..82adbc08e 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagementTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyManagementTest.java @@ -1,71 +1,71 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.StringReader; - -import org.jdom.Document; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomDependencyManagementTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test - public void testGetDependencies() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - assertNotNull( new JDomDependencyManagement( document.getRootElement() ).getDependencies() ); - assertEquals( 0, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 0, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); - - content = ""; - document = builder.build( new StringReader( content ) ); - assertEquals( 1, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); - } - - // All other methods throw UnsupportedOperationException - - @Test( expected = UnsupportedOperationException.class ) - public void testAddDependency() - { - new JDomDependencyManagement( null ).addDependency( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveDependency() - { - new JDomDependencyManagement( null ).addDependency( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetDependenciesListOfDependency() - { - new JDomDependencyManagement( null ).setDependencies( null ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.StringReader; + +import org.jdom.Document; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomDependencyManagementTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test + public void testGetDependencies() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + assertNotNull( new JDomDependencyManagement( document.getRootElement() ).getDependencies() ); + assertEquals( 0, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 0, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); + + content = ""; + document = builder.build( new StringReader( content ) ); + assertEquals( 1, new JDomDependencyManagement( document.getRootElement() ).getDependencies().size() ); + } + + // All other methods throw UnsupportedOperationException + + @Test( expected = UnsupportedOperationException.class ) + public void testAddDependency() + { + new JDomDependencyManagement( null ).addDependency( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveDependency() + { + new JDomDependencyManagement( null ).addDependency( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetDependenciesListOfDependency() + { + new JDomDependencyManagement( null ).setDependencies( null ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyTest.java index 4ba1f8b98..1cb36a2a5 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomDependencyTest.java @@ -1,186 +1,186 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.StringReader; - -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomDependencyTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test( expected = UnsupportedOperationException.class ) - public void testIsOptional() - { - new JDomDependency( null ).isOptional(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetOptional() - { - new JDomDependency( null ).setOptional( true ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testAddExclusion() - { - new JDomDependency( null ).addExclusion( null ); - } - - @Test - public void testGetArtifactId() throws Exception - { - String content = ""; - Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomDependency( dependencyElm ).getArtifactId() ); - - content = "ARTIFACTID"; - dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "ARTIFACTID", new JDomDependency( dependencyElm ).getArtifactId() ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetClassifier() - { - new JDomDependency( null ).getClassifier(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetExclusions() - { - new JDomDependency( null ).getExclusions(); - } - - @Test - public void testGetGroupId() throws Exception - { - String content = ""; - Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomDependency( dependencyElm ).getGroupId() ); - - content = "GROUPID"; - dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "GROUPID", new JDomDependency( dependencyElm ).getGroupId() ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetScope() - { - new JDomDependency( null ).getScope(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetSystemPath() - { - new JDomDependency( null ).getSystemPath(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetType() - { - new JDomDependency( null ).getType(); - } - - @Test - public void testGetVersion() throws Exception - { - String content = ""; - Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomDependency( dependencyElm ).getVersion() ); - - content = "VERSION"; - dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "VERSION", new JDomDependency( dependencyElm ).getVersion() ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testRemoveExclusion() - { - new JDomDependency( null ).removeExclusion( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetArtifactIdString() - { - new JDomDependency( null ).setArtifactId( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetClassifierString() - { - new JDomDependency( null ).setClassifier( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetExclusions() - { - new JDomDependency( null ).setExclusions( null );; - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetGroupIdString() - { - new JDomDependency( null ).setGroupId( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetScopeString() - { - new JDomDependency( null ).setScope( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetSystemPathString() - { - new JDomDependency( null ).setSystemPath( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetTypeString() - { - new JDomDependency( null ).setType( null ); - } - - @Test - public void testSetVersionString() throws Exception - { - String content = "OLD_VERSION"; - Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); - new JDomDependency( dependencyElm ).setVersion( "NEW_VERSION" ); - assertEquals( "NEW_VERSION", getVersion( dependencyElm ) ); - } - - @Test - public void testGetName() - { - assertEquals( "dependency", new JDomDependency( null ).getName() ); - } - - private String getVersion( Element dependencyElm ) - { - return dependencyElm.getChildTextTrim( "version", dependencyElm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.StringReader; + +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomDependencyTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test( expected = UnsupportedOperationException.class ) + public void testIsOptional() + { + new JDomDependency( null ).isOptional(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetOptional() + { + new JDomDependency( null ).setOptional( true ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testAddExclusion() + { + new JDomDependency( null ).addExclusion( null ); + } + + @Test + public void testGetArtifactId() throws Exception + { + String content = ""; + Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomDependency( dependencyElm ).getArtifactId() ); + + content = "ARTIFACTID"; + dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "ARTIFACTID", new JDomDependency( dependencyElm ).getArtifactId() ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetClassifier() + { + new JDomDependency( null ).getClassifier(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetExclusions() + { + new JDomDependency( null ).getExclusions(); + } + + @Test + public void testGetGroupId() throws Exception + { + String content = ""; + Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomDependency( dependencyElm ).getGroupId() ); + + content = "GROUPID"; + dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "GROUPID", new JDomDependency( dependencyElm ).getGroupId() ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetScope() + { + new JDomDependency( null ).getScope(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetSystemPath() + { + new JDomDependency( null ).getSystemPath(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetType() + { + new JDomDependency( null ).getType(); + } + + @Test + public void testGetVersion() throws Exception + { + String content = ""; + Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomDependency( dependencyElm ).getVersion() ); + + content = "VERSION"; + dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "VERSION", new JDomDependency( dependencyElm ).getVersion() ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testRemoveExclusion() + { + new JDomDependency( null ).removeExclusion( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetArtifactIdString() + { + new JDomDependency( null ).setArtifactId( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetClassifierString() + { + new JDomDependency( null ).setClassifier( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetExclusions() + { + new JDomDependency( null ).setExclusions( null );; + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetGroupIdString() + { + new JDomDependency( null ).setGroupId( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetScopeString() + { + new JDomDependency( null ).setScope( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetSystemPathString() + { + new JDomDependency( null ).setSystemPath( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetTypeString() + { + new JDomDependency( null ).setType( null ); + } + + @Test + public void testSetVersionString() throws Exception + { + String content = "OLD_VERSION"; + Element dependencyElm = builder.build( new StringReader( content ) ).getRootElement(); + new JDomDependency( dependencyElm ).setVersion( "NEW_VERSION" ); + assertEquals( "NEW_VERSION", getVersion( dependencyElm ) ); + } + + @Test + public void testGetName() + { + assertEquals( "dependency", new JDomDependency( null ).getName() ); + } + + private String getVersion( Element dependencyElm ) + { + return dependencyElm.getChildTextTrim( "version", dependencyElm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomExtensionTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomExtensionTest.java index cac513fb9..c42ffdb62 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomExtensionTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomExtensionTest.java @@ -1,102 +1,102 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.StringReader; - -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomExtensionTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test - public void testGetArtifactId() throws Exception - { - String content = ""; - Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomExtension( extensionElm ).getArtifactId() ); - - content = "ARTIFACTID"; - extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "ARTIFACTID", new JDomExtension( extensionElm ).getArtifactId() ); - } - - @Test - public void testGetGroupId() throws Exception - { - String content = ""; - Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomExtension( extensionElm ).getGroupId() ); - - content = "GROUPID"; - extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "GROUPID", new JDomExtension( extensionElm ).getGroupId() ); - } - - @Test - public void testGetVersion() throws Exception - { - String content = ""; - Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomExtension( extensionElm ).getVersion() ); - - content = "VERSION"; - extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "VERSION", new JDomExtension( extensionElm ).getVersion() ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetArtifactId() - { - new JDomExtension( null ).setArtifactId( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetGroupId() - { - new JDomExtension( null ).setGroupId( null ); - } - - @Test - public void testSetVersion() throws Exception - { - String content = "OLD_VERSION"; - Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); - new JDomExtension( extensionElm ).setVersion( "NEW_VERSION" ); - assertEquals( "NEW_VERSION", getVersion( extensionElm ) ); - } - - @Test - public void testGetName() - { - assertEquals( "extension", new JDomExtension( null ).getName() ); - } - - private String getVersion( Element extensionElm ) - { - return extensionElm.getChildTextTrim( "version", extensionElm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.StringReader; + +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomExtensionTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test + public void testGetArtifactId() throws Exception + { + String content = ""; + Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomExtension( extensionElm ).getArtifactId() ); + + content = "ARTIFACTID"; + extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "ARTIFACTID", new JDomExtension( extensionElm ).getArtifactId() ); + } + + @Test + public void testGetGroupId() throws Exception + { + String content = ""; + Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomExtension( extensionElm ).getGroupId() ); + + content = "GROUPID"; + extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "GROUPID", new JDomExtension( extensionElm ).getGroupId() ); + } + + @Test + public void testGetVersion() throws Exception + { + String content = ""; + Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomExtension( extensionElm ).getVersion() ); + + content = "VERSION"; + extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "VERSION", new JDomExtension( extensionElm ).getVersion() ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetArtifactId() + { + new JDomExtension( null ).setArtifactId( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetGroupId() + { + new JDomExtension( null ).setGroupId( null ); + } + + @Test + public void testSetVersion() throws Exception + { + String content = "OLD_VERSION"; + Element extensionElm = builder.build( new StringReader( content ) ).getRootElement(); + new JDomExtension( extensionElm ).setVersion( "NEW_VERSION" ); + assertEquals( "NEW_VERSION", getVersion( extensionElm ) ); + } + + @Test + public void testGetName() + { + assertEquals( "extension", new JDomExtension( null ).getName() ); + } + + private String getVersion( Element extensionElm ) + { + return extensionElm.getChildTextTrim( "version", extensionElm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomModelTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomModelTest.java index 32be37b7b..e17f0711d 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomModelTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomModelTest.java @@ -1,98 +1,98 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.io.StringReader; - -import org.apache.maven.model.Model; -import org.apache.maven.model.Scm; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomModelTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test - public void testGetScm() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - assertNull( new JDomModel( document ).getScm() ); - } - - @Test - public void testSetScm() throws Exception - { - String content = ""; - Document document = builder.build( new StringReader( content ) ); - Model model = new JDomModel( document ); - assertNull( model.getScm() ); - - model.setScm( new Scm() ); - assertNotNull( model.getScm() ); - - model.setScm( null ); - assertNull( model.getScm() ); - } - - @Test - public void testSetVersion() throws Exception - { - String content = ""; - Element projectElm = builder.build( new StringReader( content ) ).getRootElement(); - Model model = new JDomModel( projectElm ); - assertNull( model.getVersion() ); - - model.setVersion( "VERSION" ); - assertEquals( "VERSION", getVersion( projectElm ) ); - - model.setVersion( null ); - assertNull( model.getVersion() ); - - // inherit from parent - // this business logic might need to moved. - content = "PARENT_VERSION"; - projectElm = builder.build( new StringReader( content ) ).getRootElement(); - model = new JDomModel( projectElm ); - assertNull( model.getVersion() ); - - model.setVersion( "PARENT_VERSION" ); - assertNull( getVersion( projectElm ) ); - - model.setVersion( "VERSION" ); - assertEquals( "VERSION", getVersion( projectElm ) ); - - model.setVersion( null ); - assertNull( model.getVersion() ); - } - - private String getVersion( Element projectElm ) - { - return projectElm.getChildText( "version", projectElm.getNamespace() ); - } - -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import java.io.StringReader; + +import org.apache.maven.model.Model; +import org.apache.maven.model.Scm; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomModelTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test + public void testGetScm() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + assertNull( new JDomModel( document ).getScm() ); + } + + @Test + public void testSetScm() throws Exception + { + String content = ""; + Document document = builder.build( new StringReader( content ) ); + Model model = new JDomModel( document ); + assertNull( model.getScm() ); + + model.setScm( new Scm() ); + assertNotNull( model.getScm() ); + + model.setScm( null ); + assertNull( model.getScm() ); + } + + @Test + public void testSetVersion() throws Exception + { + String content = ""; + Element projectElm = builder.build( new StringReader( content ) ).getRootElement(); + Model model = new JDomModel( projectElm ); + assertNull( model.getVersion() ); + + model.setVersion( "VERSION" ); + assertEquals( "VERSION", getVersion( projectElm ) ); + + model.setVersion( null ); + assertNull( model.getVersion() ); + + // inherit from parent + // this business logic might need to moved. + content = "PARENT_VERSION"; + projectElm = builder.build( new StringReader( content ) ).getRootElement(); + model = new JDomModel( projectElm ); + assertNull( model.getVersion() ); + + model.setVersion( "PARENT_VERSION" ); + assertNull( getVersion( projectElm ) ); + + model.setVersion( "VERSION" ); + assertEquals( "VERSION", getVersion( projectElm ) ); + + model.setVersion( null ); + assertNull( model.getVersion() ); + } + + private String getVersion( Element projectElm ) + { + return projectElm.getChildText( "version", projectElm.getNamespace() ); + } + +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomParentTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomParentTest.java index b88d9f1b0..1cc0a59e8 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomParentTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomParentTest.java @@ -1,101 +1,101 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.*; - -import java.io.StringReader; - -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomParentTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test( expected = UnsupportedOperationException.class ) - public void testGetArtifactId() - { - new JDomParent( null ).getArtifactId(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetGroupId() - { - new JDomParent( null ).getGroupId(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetRelativePath() - { - new JDomParent( null ).getRelativePath(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetVersion() - { - new JDomParent( null ).getVersion(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetArtifactId() - { - new JDomParent( null ).setArtifactId( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetGroupId() - { - new JDomParent( null ).setGroupId( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSetRelativePath() - { - new JDomParent( null ).setRelativePath( null ); - } - - @Test - public void testSetVersionString() throws Exception - { - String content = ""; - Element parentElm = builder.build( new StringReader( content ) ).getRootElement(); - - assertNull( getVersion( parentElm ) ); - - new JDomParent( parentElm ).setVersion( "VERSION" ); - assertEquals( "VERSION", getVersion( parentElm ) ); - - new JDomParent( parentElm ).setVersion( null ); - assertNull( getVersion( parentElm ) ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetId() - { - new JDomParent( null ).getId(); - } - - private String getVersion( Element parentElm ) - { - return parentElm.getChildText( "version", parentElm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.*; + +import java.io.StringReader; + +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomParentTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test( expected = UnsupportedOperationException.class ) + public void testGetArtifactId() + { + new JDomParent( null ).getArtifactId(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetGroupId() + { + new JDomParent( null ).getGroupId(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetRelativePath() + { + new JDomParent( null ).getRelativePath(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetVersion() + { + new JDomParent( null ).getVersion(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetArtifactId() + { + new JDomParent( null ).setArtifactId( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetGroupId() + { + new JDomParent( null ).setGroupId( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSetRelativePath() + { + new JDomParent( null ).setRelativePath( null ); + } + + @Test + public void testSetVersionString() throws Exception + { + String content = ""; + Element parentElm = builder.build( new StringReader( content ) ).getRootElement(); + + assertNull( getVersion( parentElm ) ); + + new JDomParent( parentElm ).setVersion( "VERSION" ); + assertEquals( "VERSION", getVersion( parentElm ) ); + + new JDomParent( parentElm ).setVersion( null ); + assertNull( getVersion( parentElm ) ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetId() + { + new JDomParent( null ).getId(); + } + + private String getVersion( Element parentElm ) + { + return parentElm.getChildText( "version", parentElm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomPropertiesTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomPropertiesTest.java index a82bec53a..71b847ea3 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomPropertiesTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomPropertiesTest.java @@ -1,157 +1,157 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.io.Reader; -import java.io.StringReader; -import java.io.Writer; - -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomPropertiesTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test - public void testSetProperty() throws Exception - { - String content = ""; - Element propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( getProperty( propertiesElm, "KEY" ) ); - - // Adding not allowed, prepare properties - content = "OLD_VALUE"; - propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "OLD_VALUE", getProperty( propertiesElm, "KEY" ) ); - new JDomProperties( propertiesElm ).setProperty( "KEY", "NEW_VALUE" ); - assertEquals( "NEW_VALUE", getProperty( propertiesElm, "KEY" ) ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testLoadReader() - throws Exception - { - new JDomProperties( null ).load( (Reader) null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testLoadInputStream() - throws Exception - { - new JDomProperties( null ).load( (InputStream) null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testSave() - { - new JDomProperties( null ).save( null, null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testStoreWriter() - throws Exception - { - new JDomProperties( null ).store( (Writer) null, null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testStoreOutputStream() - throws Exception - { - new JDomProperties( null ).store( (OutputStream) null, null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testLoadFromXML() - throws Exception - { - new JDomProperties( null ).loadFromXML( null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testStoreToXML() - throws Exception - { - new JDomProperties( null ).storeToXML( null, null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testStoreToXMLEncoded() - throws Exception - { - new JDomProperties( null ).storeToXML( (OutputStream) null, null, (String) null ); - } - - @Test - public void testGetProperty() throws Exception - { - String content = ""; - Element propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); - assertNull( new JDomProperties( propertiesElm ).getProperty( "KEY" ) ); - - content = "VALUE"; - propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); - assertEquals( "VALUE", new JDomProperties( propertiesElm ).getProperty( "KEY" ) ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetPropertyDefault() - { - new JDomProperties( null ).getProperty( null, null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testPropertyNames() - { - new JDomProperties( null ).propertyNames(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testStringPropertyNames() - { - new JDomProperties( null ).stringPropertyNames(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testListPrintStream() - { - new JDomProperties( null ).list( (PrintStream) null ); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testListPrintWriter() - { - new JDomProperties( null ).list( (PrintWriter) null ); - } - - private String getProperty( Element propertiesElm, String key ) - { - return propertiesElm.getChildText( key, propertiesElm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.StringReader; +import java.io.Writer; + +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomPropertiesTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test + public void testSetProperty() throws Exception + { + String content = ""; + Element propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( getProperty( propertiesElm, "KEY" ) ); + + // Adding not allowed, prepare properties + content = "OLD_VALUE"; + propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "OLD_VALUE", getProperty( propertiesElm, "KEY" ) ); + new JDomProperties( propertiesElm ).setProperty( "KEY", "NEW_VALUE" ); + assertEquals( "NEW_VALUE", getProperty( propertiesElm, "KEY" ) ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testLoadReader() + throws Exception + { + new JDomProperties( null ).load( (Reader) null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testLoadInputStream() + throws Exception + { + new JDomProperties( null ).load( (InputStream) null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testSave() + { + new JDomProperties( null ).save( null, null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testStoreWriter() + throws Exception + { + new JDomProperties( null ).store( (Writer) null, null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testStoreOutputStream() + throws Exception + { + new JDomProperties( null ).store( (OutputStream) null, null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testLoadFromXML() + throws Exception + { + new JDomProperties( null ).loadFromXML( null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testStoreToXML() + throws Exception + { + new JDomProperties( null ).storeToXML( null, null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testStoreToXMLEncoded() + throws Exception + { + new JDomProperties( null ).storeToXML( (OutputStream) null, null, (String) null ); + } + + @Test + public void testGetProperty() throws Exception + { + String content = ""; + Element propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); + assertNull( new JDomProperties( propertiesElm ).getProperty( "KEY" ) ); + + content = "VALUE"; + propertiesElm = builder.build( new StringReader( content ) ).getRootElement(); + assertEquals( "VALUE", new JDomProperties( propertiesElm ).getProperty( "KEY" ) ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetPropertyDefault() + { + new JDomProperties( null ).getProperty( null, null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testPropertyNames() + { + new JDomProperties( null ).propertyNames(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testStringPropertyNames() + { + new JDomProperties( null ).stringPropertyNames(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testListPrintStream() + { + new JDomProperties( null ).list( (PrintStream) null ); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testListPrintWriter() + { + new JDomProperties( null ).list( (PrintWriter) null ); + } + + private String getProperty( Element propertiesElm, String key ) + { + return propertiesElm.getChildText( key, propertiesElm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomScmTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomScmTest.java index 664cb37b4..d9faa90d9 100644 --- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomScmTest.java +++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/transform/jdom/JDomScmTest.java @@ -1,138 +1,138 @@ -package org.apache.maven.shared.release.transform.jdom; - -/* - * 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 static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.StringReader; - -import org.jdom.Element; -import org.jdom.input.SAXBuilder; -import org.junit.Test; - -public class JDomScmTest -{ - private SAXBuilder builder = new SAXBuilder(); - - @Test( expected = UnsupportedOperationException.class ) - public void testGetConnection() - { - new JDomScm( null ).getConnection(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetDeveloperConnection() - { - new JDomScm( null ).getDeveloperConnection(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetTag() - { - new JDomScm( null ).getTag(); - } - - @Test( expected = UnsupportedOperationException.class ) - public void testGetUrl() - { - new JDomScm( null ).getUrl(); - } - - @Test - public void testSetConnectionString() throws Exception - { - String content = ""; - Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); - - assertNull( getConnection( scmElm ) ); - - new JDomScm( scmElm ).setConnection( "CONNECTION" ); - assertEquals( "CONNECTION", getConnection( scmElm ) ); - - new JDomScm( scmElm ).setConnection( null ); - assertNull( getConnection( scmElm ) ); - } - - @Test - public void testSetDeveloperConnectionString() throws Exception - { - String content = ""; - Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); - - assertNull( getDeveloperConnection( scmElm ) ); - - new JDomScm( scmElm ).setDeveloperConnection( "DEVELOPERCONNECTION" ); - assertEquals( "DEVELOPERCONNECTION", getDeveloperConnection( scmElm ) ); - - new JDomScm( scmElm ).setDeveloperConnection( null ); - assertNull( getDeveloperConnection( scmElm ) ); - } - - @Test - public void testSetTagString() throws Exception - { - String content = ""; - Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); - - assertNull( getUrl( scmElm ) ); - - new JDomScm( scmElm ).setUrl( "URL" ); - assertEquals( "URL", getUrl( scmElm ) ); - - new JDomScm( scmElm ).setUrl( null ); - assertNull( getUrl( scmElm ) ); - } - - @Test - public void testSetUrlString() throws Exception - { - String content = ""; - Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); - - assertNull( getTag( scmElm ) ); - - new JDomScm( scmElm ).setTag( "TAG" ); - assertEquals( "TAG", getTag( scmElm ) ); - - new JDomScm( scmElm ).setTag( null ); - assertNull( getTag( scmElm ) ); - } - - private String getConnection( Element scmElm ) - { - return scmElm.getChildText( "connection", scmElm.getNamespace() ); - } - - private String getDeveloperConnection( Element scmElm ) - { - return scmElm.getChildText( "developerConnection", scmElm.getNamespace() ); - } - - private String getTag( Element scmElm ) - { - return scmElm.getChildText( "tag", scmElm.getNamespace() ); - } - - private String getUrl( Element scmElm ) - { - return scmElm.getChildText( "url", scmElm.getNamespace() ); - } -} +package org.apache.maven.shared.release.transform.jdom; + +/* + * 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.StringReader; + +import org.jdom.Element; +import org.jdom.input.SAXBuilder; +import org.junit.Test; + +public class JDomScmTest +{ + private SAXBuilder builder = new SAXBuilder(); + + @Test( expected = UnsupportedOperationException.class ) + public void testGetConnection() + { + new JDomScm( null ).getConnection(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetDeveloperConnection() + { + new JDomScm( null ).getDeveloperConnection(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetTag() + { + new JDomScm( null ).getTag(); + } + + @Test( expected = UnsupportedOperationException.class ) + public void testGetUrl() + { + new JDomScm( null ).getUrl(); + } + + @Test + public void testSetConnectionString() throws Exception + { + String content = ""; + Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); + + assertNull( getConnection( scmElm ) ); + + new JDomScm( scmElm ).setConnection( "CONNECTION" ); + assertEquals( "CONNECTION", getConnection( scmElm ) ); + + new JDomScm( scmElm ).setConnection( null ); + assertNull( getConnection( scmElm ) ); + } + + @Test + public void testSetDeveloperConnectionString() throws Exception + { + String content = ""; + Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); + + assertNull( getDeveloperConnection( scmElm ) ); + + new JDomScm( scmElm ).setDeveloperConnection( "DEVELOPERCONNECTION" ); + assertEquals( "DEVELOPERCONNECTION", getDeveloperConnection( scmElm ) ); + + new JDomScm( scmElm ).setDeveloperConnection( null ); + assertNull( getDeveloperConnection( scmElm ) ); + } + + @Test + public void testSetTagString() throws Exception + { + String content = ""; + Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); + + assertNull( getUrl( scmElm ) ); + + new JDomScm( scmElm ).setUrl( "URL" ); + assertEquals( "URL", getUrl( scmElm ) ); + + new JDomScm( scmElm ).setUrl( null ); + assertNull( getUrl( scmElm ) ); + } + + @Test + public void testSetUrlString() throws Exception + { + String content = ""; + Element scmElm = builder.build( new StringReader( content ) ).getRootElement(); + + assertNull( getTag( scmElm ) ); + + new JDomScm( scmElm ).setTag( "TAG" ); + assertEquals( "TAG", getTag( scmElm ) ); + + new JDomScm( scmElm ).setTag( null ); + assertNull( getTag( scmElm ) ); + } + + private String getConnection( Element scmElm ) + { + return scmElm.getChildText( "connection", scmElm.getNamespace() ); + } + + private String getDeveloperConnection( Element scmElm ) + { + return scmElm.getChildText( "developerConnection", scmElm.getNamespace() ); + } + + private String getTag( Element scmElm ) + { + return scmElm.getChildText( "tag", scmElm.getNamespace() ); + } + + private String getUrl( Element scmElm ) + { + return scmElm.getChildText( "url", scmElm.getNamespace() ); + } +} diff --git a/maven-release-manager/src/test/remote-repository/groupId/subproject1/1.0-SNAPSHOT/subproject1-1.0-SNAPSHOT.jar b/maven-release-manager/src/test/remote-repository/groupId/subproject1/1.0-SNAPSHOT/subproject1-1.0-SNAPSHOT.jar index 84735bb44..421376db9 100644 --- a/maven-release-manager/src/test/remote-repository/groupId/subproject1/1.0-SNAPSHOT/subproject1-1.0-SNAPSHOT.jar +++ b/maven-release-manager/src/test/remote-repository/groupId/subproject1/1.0-SNAPSHOT/subproject1-1.0-SNAPSHOT.jar @@ -1 +1 @@ -dummy +dummy diff --git a/maven-release-manager/src/test/remote-repository/groupId/subproject1/2.0/subproject1-2.0.jar b/maven-release-manager/src/test/remote-repository/groupId/subproject1/2.0/subproject1-2.0.jar index 84735bb44..421376db9 100644 --- a/maven-release-manager/src/test/remote-repository/groupId/subproject1/2.0/subproject1-2.0.jar +++ b/maven-release-manager/src/test/remote-repository/groupId/subproject1/2.0/subproject1-2.0.jar @@ -1 +1 @@ -dummy +dummy diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/pom.xml index 133cb6ad5..ff953014b 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/pom.xml @@ -1,96 +1,96 @@ - - - - - 4.0.0 - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - This is the base POM the release test modules - pom - O2 Release test Base Module - - release-test-module-one - release-test-module-two - - - scm:git|sd_pa/tools/release-test - - - - - - org.apache.maven.plugin.release.its - release-test-module-one - 1.0-SNAPSHOT - - - - org.apache.maven.plugin.release.its - release-test-module-one - 1.0-SNAPSHOT - test-jar - test - - - - - - - - - org.apache.maven.plugins - maven-release-plugin - @project.version@ - - - - - - org.apache.maven.plugins - maven-source-plugin - - - package - - jar - - - - - - - - - o2-webdav - ${repository.o2.webdav} - - - o2-webdav - ${repository.o2.webdav} - - - - dav:${o2.module.sites.rootUrl}/${project.groupId}/${project.artifactId}-${project.version} - - - + + + + + 4.0.0 + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + This is the base POM the release test modules + pom + O2 Release test Base Module + + release-test-module-one + release-test-module-two + + + scm:git|sd_pa/tools/release-test + + + + + + org.apache.maven.plugin.release.its + release-test-module-one + 1.0-SNAPSHOT + + + + org.apache.maven.plugin.release.its + release-test-module-one + 1.0-SNAPSHOT + test-jar + test + + + + + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + + + + + org.apache.maven.plugins + maven-source-plugin + + + package + + jar + + + + + + + + + o2-webdav + ${repository.o2.webdav} + + + o2-webdav + ${repository.o2.webdav} + + + + dav:${o2.module.sites.rootUrl}/${project.groupId}/${project.artifactId}-${project.version} + + + diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-one/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-one/pom.xml index aac087037..139b52a1a 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-one/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-one/pom.xml @@ -1,49 +1,49 @@ - - - - - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - - 4.0.0 - release-test-module-one - 1.0-SNAPSHOT - release-test-module-one - http://maven.apache.org - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - + + + + + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + + 4.0.0 + release-test-module-one + 1.0-SNAPSHOT + release-test-module-one + http://maven.apache.org + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-two/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-two/pom.xml index 0e494b92b..5ff976872 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-two/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161-dependencyManagement/release-test-module-two/pom.xml @@ -1,47 +1,47 @@ - - - - - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - - 4.0.0 - release-test-module-two - release-test-module-two - 1.0-SNAPSHOT - http://maven.apache.org - - - - org.apache.maven.plugin.release.its - release-test-module-one - - - - org.apache.maven.plugin.release.its - release-test-module-one - test-jar - test - - - + + + + + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + + 4.0.0 + release-test-module-two + release-test-module-two + 1.0-SNAPSHOT + http://maven.apache.org + + + + org.apache.maven.plugin.release.its + release-test-module-one + + + + org.apache.maven.plugin.release.its + release-test-module-one + test-jar + test + + + \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/pom.xml index 1beecc75a..8cd6dc024 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/pom.xml @@ -1,77 +1,77 @@ - - - - - 4.0.0 - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - This is the base POM the release test modules - pom - O2 Release test Base Module - - release-test-module-one - release-test-module-two - - - scm:git|sd_pa/tools/release-test - - - - - - org.apache.maven.plugins - maven-release-plugin - @project.version@ - - - - - - org.apache.maven.plugins - maven-source-plugin - - - package - - jar - - - - - - - - - o2-webdav - ${repository.o2.webdav} - - - o2-webdav - ${repository.o2.webdav} - - - - dav:${o2.module.sites.rootUrl}/${project.groupId}/${project.artifactId}-${project.version} - - - + + + + + 4.0.0 + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + This is the base POM the release test modules + pom + O2 Release test Base Module + + release-test-module-one + release-test-module-two + + + scm:git|sd_pa/tools/release-test + + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + + + + + org.apache.maven.plugins + maven-source-plugin + + + package + + jar + + + + + + + + + o2-webdav + ${repository.o2.webdav} + + + o2-webdav + ${repository.o2.webdav} + + + + dav:${o2.module.sites.rootUrl}/${project.groupId}/${project.artifactId}-${project.version} + + + diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-one/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-one/pom.xml index aac087037..139b52a1a 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-one/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-one/pom.xml @@ -1,49 +1,49 @@ - - - - - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - - 4.0.0 - release-test-module-one - 1.0-SNAPSHOT - release-test-module-one - http://maven.apache.org - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - + + + + + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + + 4.0.0 + release-test-module-one + 1.0-SNAPSHOT + release-test-module-one + http://maven.apache.org + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-two/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-two/pom.xml index 0a2ed5fda..4906246bb 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-two/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-161/release-test-module-two/pom.xml @@ -1,49 +1,49 @@ - - - - - org.apache.maven.plugin.release.its - mrelease-161 - 1.0-SNAPSHOT - - 4.0.0 - release-test-module-two - release-test-module-two - 1.0-SNAPSHOT - http://maven.apache.org - - - - org.apache.maven.plugin.release.its - release-test-module-one - 1.0-SNAPSHOT - - - - org.apache.maven.plugin.release.its - release-test-module-one - 1.0-SNAPSHOT - test-jar - test - - - + + + + + org.apache.maven.plugin.release.its + mrelease-161 + 1.0-SNAPSHOT + + 4.0.0 + release-test-module-two + release-test-module-two + 1.0-SNAPSHOT + http://maven.apache.org + + + + org.apache.maven.plugin.release.its + release-test-module-one + 1.0-SNAPSHOT + + + + org.apache.maven.plugin.release.its + release-test-module-one + 1.0-SNAPSHOT + test-jar + test + + + \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/pom.xml b/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/pom.xml index c031b78fd..ad9190851 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/pom.xml +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/pom.xml @@ -1,44 +1,44 @@ - - - - 4.0.0 - - org.apache.maven.plugin.release.its - mrelease-834 - 1.0-SNAPSHOT - pom - - - scm:dummy|nul - scm:dummy|nul - - - - - - org.apache.maven.plugins - maven-release-plugin - @project.version@ - - - org.apache.maven.its.release - maven-scm-provider-dummy - 1.0 - - - - - - + + + + 4.0.0 + + org.apache.maven.plugin.release.its + mrelease-834 + 1.0-SNAPSHOT + pom + + + scm:dummy|nul + scm:dummy|nul + + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + + org.apache.maven.its.release + maven-scm-provider-dummy + 1.0 + + + + + + \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/test.properties b/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/test.properties index 3fc1992a6..5ba71e6f7 100644 --- a/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/test.properties +++ b/maven-release-plugin/src/it/projects/prepare/MRELEASE-834/test.properties @@ -1,18 +1,18 @@ -# 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. - +# 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. + dependency.locations.enabled=false \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-a/pom.xml b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-a/pom.xml index 9df4fde2f..defc6bab8 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-a/pom.xml +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-a/pom.xml @@ -1,29 +1,29 @@ - - - - 4.0.0 - - org.apache.maven.plugin.release.its - mrelease-555 - 1.0-SNAPSHOT - - - module-a - + + + + 4.0.0 + + org.apache.maven.plugin.release.its + mrelease-555 + 1.0-SNAPSHOT + + + module-a + diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-b/pom.xml b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-b/pom.xml index f15f5a224..96d119319 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-b/pom.xml +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/module-b/pom.xml @@ -1,37 +1,37 @@ - - - - 4.0.0 - - org.apache.maven.plugin.release.its - mrelease-555 - 1.0-SNAPSHOT - - module-b - 1.0-SNAPSHOT - - - - org.apache.maven.plugin.release.its - module-a - 1.0-SNAPSHOT - - - + + + + 4.0.0 + + org.apache.maven.plugin.release.its + mrelease-555 + 1.0-SNAPSHOT + + module-b + 1.0-SNAPSHOT + + + + org.apache.maven.plugin.release.its + module-a + 1.0-SNAPSHOT + + + diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/pom.xml b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/pom.xml index 4718e3d4b..7915866be 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/pom.xml +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/pom.xml @@ -1,45 +1,45 @@ - - - - 4.0.0 - org.apache.maven.plugin.release.its - mrelease-555 - pom - 1.0-SNAPSHOT - - http://jira.codehaus.org/browse/MRELEASE-555 - - - - - - org.apache.maven.plugins - maven-release-plugin - @project.version@ - - - - - - - module-a - module-b - - + + + + 4.0.0 + org.apache.maven.plugin.release.its + mrelease-555 + pom + 1.0-SNAPSHOT + + http://jira.codehaus.org/browse/MRELEASE-555 + + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + + + + + + module-a + module-b + + diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/verify.groovy b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/verify.groovy index ec16ecd89..e1d930373 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/verify.groovy +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-555/verify.groovy @@ -1,28 +1,28 @@ - -/* - * 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. - */ - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() - -def projectRoot = new XmlSlurper().parse( new File( basedir, "module-b/pom.xml" ) ) - -assert projectRoot.dependencies.dependency.version.text() == "1.1-SNAPSHOT" - + +/* + * 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. + */ + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +def projectRoot = new XmlSlurper().parse( new File( basedir, "module-b/pom.xml" ) ) + +assert projectRoot.dependencies.dependency.version.text() == "1.1-SNAPSHOT" + return true \ No newline at end of file diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/pom.xml b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/pom.xml index 41312c0f0..67a2b403a 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/pom.xml +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/pom.xml @@ -1,41 +1,41 @@ - - - - 4.0.0 - - org.apache.maven.its.release - mrelease-661 - 1.0 - pom - - http://jira.codehaus.org/browse/MRELEASE-611 - - Ensure you can update from a non-SNAPSHOT project - - - - - org.apache.maven.plugins - maven-release-plugin - @project.version@ - - - - + + + + 4.0.0 + + org.apache.maven.its.release + mrelease-661 + 1.0 + pom + + http://jira.codehaus.org/browse/MRELEASE-611 + + Ensure you can update from a non-SNAPSHOT project + + + + + org.apache.maven.plugins + maven-release-plugin + @project.version@ + + + + diff --git a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/verify.groovy b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/verify.groovy index b87eb47c5..369c62546 100644 --- a/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/verify.groovy +++ b/maven-release-plugin/src/it/projects/update-versions/MRELEASE-611/verify.groovy @@ -1,28 +1,28 @@ - -/* - * 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. - */ - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() - -def projectRoot = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) - -assert projectRoot.version.text() == "1.1-SNAPSHOT" - + +/* + * 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. + */ + +File buildLog = new File( basedir, 'build.log' ) +assert buildLog.exists() + +def projectRoot = new XmlSlurper().parse( new File( basedir, "pom.xml" ) ) + +assert projectRoot.version.text() == "1.1-SNAPSHOT" + return true \ No newline at end of file diff --git a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/invoker.properties b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/invoker.properties index 2ee0f98c0..97189ec2e 100644 --- a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/invoker.properties +++ b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/invoker.properties @@ -1,18 +1,18 @@ -# 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. - -invoker.goals = install +# 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. + +invoker.goals = install diff --git a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/pom.xml b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/pom.xml index 86aa79dfd..5a5a96edb 100644 --- a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/pom.xml +++ b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/pom.xml @@ -1,61 +1,61 @@ - - - - - 4.0.0 - - org.apache.maven.its.release - maven-project-naming-stub-policy - 1.0 - - - - org.apache.maven.release - maven-release-manager - @project.version@ - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - UTF-8 - - - - org.codehaus.plexus - plexus-component-metadata - 1.7.1 - - - process-classes - - generate-metadata - - - - - - - + + + + + 4.0.0 + + org.apache.maven.its.release + maven-project-naming-stub-policy + 1.0 + + + + org.apache.maven.release + maven-release-manager + @project.version@ + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + UTF-8 + + + + org.codehaus.plexus + plexus-component-metadata + 1.7.1 + + + process-classes + + generate-metadata + + + + + + + diff --git a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/src/main/java/org/apache/maven/shared/release/policy/stub/StubNamingPolicy.java b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/src/main/java/org/apache/maven/shared/release/policy/stub/StubNamingPolicy.java index ea4642675..d784a5bdd 100644 --- a/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/src/main/java/org/apache/maven/shared/release/policy/stub/StubNamingPolicy.java +++ b/maven-release-plugin/src/it/setup/maven-project-naming-stub-policy/src/main/java/org/apache/maven/shared/release/policy/stub/StubNamingPolicy.java @@ -1,38 +1,38 @@ -package org.apache.maven.shared.release.policy.stub; - -/* - * 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.shared.release.policy.naming.NamingPolicy; -import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; -import org.apache.maven.shared.release.policy.naming.NamingPolicyResult; - -import org.codehaus.plexus.component.annotations.Component; - -@Component( role = NamingPolicy.class, hint = "StubNamingPolicy" ) -public final class StubNamingPolicy - implements NamingPolicy -{ - - public NamingPolicyResult getName( NamingPolicyRequest request ) - { - return new NamingPolicyResult().setName( "STUB" ); - } - -} +package org.apache.maven.shared.release.policy.stub; + +/* + * 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.shared.release.policy.naming.NamingPolicy; +import org.apache.maven.shared.release.policy.naming.NamingPolicyRequest; +import org.apache.maven.shared.release.policy.naming.NamingPolicyResult; + +import org.codehaus.plexus.component.annotations.Component; + +@Component( role = NamingPolicy.class, hint = "StubNamingPolicy" ) +public final class StubNamingPolicy + implements NamingPolicy +{ + + public NamingPolicyResult getName( NamingPolicyRequest request ) + { + return new NamingPolicyResult().setName( "STUB" ); + } + +} diff --git a/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java b/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java index 68327c23c..0a20c620c 100644 --- a/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java +++ b/maven-release-policies/maven-release-semver-policy/src/main/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicy.java @@ -1,80 +1,80 @@ -package org.apache.maven.shared.release.policy.semver; - -/* - * 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.shared.release.policy.PolicyException; -import org.apache.maven.shared.release.policy.version.VersionPolicy; -import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; -import org.apache.maven.shared.release.policy.version.VersionPolicyResult; -import org.apache.maven.shared.release.versions.VersionParseException; -import org.codehaus.plexus.component.annotations.Component; -import org.semver.Version; -import org.semver.Version.Element; - -/** - * - * Uses SemVer implementation to increase minor element when resolving the development version - * - */ -@Component( - role = VersionPolicy.class, - hint = "SemVerVersionPolicy", - description = "A VersionPolicy following the SemVer rules" - ) -public class SemVerVersionPolicy implements VersionPolicy -{ - - public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException - { - Version version; - try - { - version = Version.parse( request.getVersion() ); - } - catch ( IllegalArgumentException e ) - { - throw new VersionParseException( e.getMessage() ); - } - - VersionPolicyResult result = new VersionPolicyResult(); - result.setVersion( version.toReleaseVersion().toString() ); - return result; - } - - public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) - throws PolicyException, VersionParseException - { - Version version; - try - { - version = Version.parse( request.getVersion() ); - } - catch ( IllegalArgumentException e ) - { - throw new VersionParseException( e.getMessage() ); - } - - version = version.next( Element.MINOR ); - VersionPolicyResult result = new VersionPolicyResult(); - result.setVersion( version.toString() + "-SNAPSHOT" ); - return result; - } -} +package org.apache.maven.shared.release.policy.semver; + +/* + * 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.shared.release.policy.PolicyException; +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; +import org.apache.maven.shared.release.policy.version.VersionPolicyResult; +import org.apache.maven.shared.release.versions.VersionParseException; +import org.codehaus.plexus.component.annotations.Component; +import org.semver.Version; +import org.semver.Version.Element; + +/** + * + * Uses SemVer implementation to increase minor element when resolving the development version + * + */ +@Component( + role = VersionPolicy.class, + hint = "SemVerVersionPolicy", + description = "A VersionPolicy following the SemVer rules" + ) +public class SemVerVersionPolicy implements VersionPolicy +{ + + public VersionPolicyResult getReleaseVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException + { + Version version; + try + { + version = Version.parse( request.getVersion() ); + } + catch ( IllegalArgumentException e ) + { + throw new VersionParseException( e.getMessage() ); + } + + VersionPolicyResult result = new VersionPolicyResult(); + result.setVersion( version.toReleaseVersion().toString() ); + return result; + } + + public VersionPolicyResult getDevelopmentVersion( VersionPolicyRequest request ) + throws PolicyException, VersionParseException + { + Version version; + try + { + version = Version.parse( request.getVersion() ); + } + catch ( IllegalArgumentException e ) + { + throw new VersionParseException( e.getMessage() ); + } + + version = version.next( Element.MINOR ); + VersionPolicyResult result = new VersionPolicyResult(); + result.setVersion( version.toString() + "-SNAPSHOT" ); + return result; + } +} diff --git a/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java b/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java index bf3763619..94bc63e29 100644 --- a/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java +++ b/maven-release-policies/maven-release-semver-policy/src/test/java/org/apache/maven/shared/release/policy/semver/SemVerVersionPolicyTest.java @@ -1,71 +1,71 @@ -package org.apache.maven.shared.release.policy.semver; - -/* - * 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 static org.junit.Assert.*; - -import org.apache.maven.shared.release.policy.version.VersionPolicy; -import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class SemVerVersionPolicyTest -{ - - private VersionPolicy versionPolicy; - - @Before - public void setUp() - { - versionPolicy = new SemVerVersionPolicy(); - } - - @After - public void tearDown() - { - versionPolicy = null; - } - - @Test - public void testConvertToSnapshot() - throws Exception - { - String suggestedVersion = versionPolicy.getDevelopmentVersion( newVersionPolicyRequest( "1.0.0" ) ) - .getVersion(); - - assertEquals( "1.1.0-SNAPSHOT", suggestedVersion ); - } - - @Test - public void testConvertToRelease() - throws Exception - { - String suggestedVersion = versionPolicy.getReleaseVersion( newVersionPolicyRequest( "1.0.0-SNAPSHOT" ) ) - .getVersion(); - - assertEquals( "1.0.0", suggestedVersion ); - } - - private static VersionPolicyRequest newVersionPolicyRequest( String version ) - { - return new VersionPolicyRequest().setVersion( version ); - } -} +package org.apache.maven.shared.release.policy.semver; + +/* + * 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 static org.junit.Assert.*; + +import org.apache.maven.shared.release.policy.version.VersionPolicy; +import org.apache.maven.shared.release.policy.version.VersionPolicyRequest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class SemVerVersionPolicyTest +{ + + private VersionPolicy versionPolicy; + + @Before + public void setUp() + { + versionPolicy = new SemVerVersionPolicy(); + } + + @After + public void tearDown() + { + versionPolicy = null; + } + + @Test + public void testConvertToSnapshot() + throws Exception + { + String suggestedVersion = versionPolicy.getDevelopmentVersion( newVersionPolicyRequest( "1.0.0" ) ) + .getVersion(); + + assertEquals( "1.1.0-SNAPSHOT", suggestedVersion ); + } + + @Test + public void testConvertToRelease() + throws Exception + { + String suggestedVersion = versionPolicy.getReleaseVersion( newVersionPolicyRequest( "1.0.0-SNAPSHOT" ) ) + .getVersion(); + + assertEquals( "1.0.0", suggestedVersion ); + } + + private static VersionPolicyRequest newVersionPolicyRequest( String version ) + { + return new VersionPolicyRequest().setVersion( version ); + } +}