http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Dependency.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Dependency.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Dependency.java deleted file mode 100644 index af93e86..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Dependency.java +++ /dev/null @@ -1,329 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Dependency - extends DataType - implements DependencyContainer -{ - - private String groupId; - - private String artifactId; - - private String version; - - private String classifier; - - private String type; - - private String scope; - - private File systemPath; - - private List<Exclusion> exclusions = new ArrayList<Exclusion>(); - - protected Dependency getRef() - { - return (Dependency) getCheckedRef(); - } - - public void validate( Task task ) - { - if ( isReference() ) - { - getRef().validate( task ); - } - else - { - if ( groupId == null || groupId.length() <= 0 ) - { - throw new BuildException( "You must specify the 'groupId' for a dependency" ); - } - if ( artifactId == null || artifactId.length() <= 0 ) - { - throw new BuildException( "You must specify the 'artifactId' for a dependency" ); - } - if ( version == null || version.length() <= 0 ) - { - throw new BuildException( "You must specify the 'version' for a dependency" ); - } - - if ( "system".equals( scope ) ) - { - if ( systemPath == null ) - { - throw new BuildException( "You must specify 'systemPath' for dependencies with scope=system" ); - } - } - else if ( systemPath != null ) - { - throw new BuildException( "You may only specify 'systemPath' for dependencies with scope=system" ); - } - - if ( scope != null && !"compile".equals( scope ) && !"provided".equals( scope ) && !"system".equals( scope ) - && !"runtime".equals( scope ) && !"test".equals( scope ) ) - { - task.log( "Unknown scope '" + scope + "' for dependency", Project.MSG_WARN ); - } - - for ( Exclusion exclusion : exclusions ) - { - exclusion.validate( task ); - } - } - } - - public void setRefid( Reference ref ) - { - if ( groupId != null || artifactId != null || type != null || classifier != null || version != null - || scope != null || systemPath != null ) - { - throw tooManyAttributes(); - } - if ( !exclusions.isEmpty() ) - { - throw noChildrenAllowed(); - } - super.setRefid( ref ); - } - - public String getGroupId() - { - if ( isReference() ) - { - return getRef().getGroupId(); - } - return groupId; - } - - public void setGroupId( String groupId ) - { - checkAttributesAllowed(); - if ( this.groupId != null ) - { - throw ambiguousCoords(); - } - this.groupId = groupId; - } - - public String getArtifactId() - { - if ( isReference() ) - { - return getRef().getArtifactId(); - } - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - checkAttributesAllowed(); - if ( this.artifactId != null ) - { - throw ambiguousCoords(); - } - this.artifactId = artifactId; - } - - public String getVersion() - { - if ( isReference() ) - { - return getRef().getVersion(); - } - return version; - } - - public void setVersion( String version ) - { - checkAttributesAllowed(); - if ( this.version != null ) - { - throw ambiguousCoords(); - } - this.version = version; - } - - public String getClassifier() - { - if ( isReference() ) - { - return getRef().getClassifier(); - } - return classifier; - } - - public void setClassifier( String classifier ) - { - checkAttributesAllowed(); - if ( this.classifier != null ) - { - throw ambiguousCoords(); - } - this.classifier = classifier; - } - - public String getType() - { - if ( isReference() ) - { - return getRef().getType(); - } - return ( type != null ) ? type : "jar"; - } - - public void setType( String type ) - { - checkAttributesAllowed(); - if ( this.type != null ) - { - throw ambiguousCoords(); - } - this.type = type; - } - - public String getScope() - { - if ( isReference() ) - { - return getRef().getScope(); - } - return ( scope != null ) ? scope : "compile"; - } - - public void setScope( String scope ) - { - checkAttributesAllowed(); - if ( this.scope != null ) - { - throw ambiguousCoords(); - } - this.scope = scope; - } - - public void setCoords( String coords ) - { - checkAttributesAllowed(); - if ( groupId != null || artifactId != null || version != null || type != null || classifier != null - || scope != null ) - { - throw ambiguousCoords(); - } - Pattern p = Pattern.compile( "([^: ]+):([^: ]+):([^: ]+)((:([^: ]+)(:([^: ]+))?)?:([^: ]+))?" ); - Matcher m = p.matcher( coords ); - if ( !m.matches() ) - { - throw new BuildException( "Bad dependency coordinates '" + coords - + "', expected format is <groupId>:<artifactId>:<version>[[:<type>[:<classifier>]]:<scope>]" ); - } - groupId = m.group( 1 ); - artifactId = m.group( 2 ); - version = m.group( 3 ); - type = m.group( 6 ); - if ( type == null || type.length() <= 0 ) - { - type = "jar"; - } - classifier = m.group( 8 ); - if ( classifier == null ) - { - classifier = ""; - } - scope = m.group( 9 ); - } - - public void setSystemPath( File systemPath ) - { - checkAttributesAllowed(); - this.systemPath = systemPath; - } - - public File getSystemPath() - { - if ( isReference() ) - { - return getRef().getSystemPath(); - } - return systemPath; - } - - public String getVersionlessKey() - { - if ( isReference() ) - { - return getRef().getVersionlessKey(); - } - StringBuilder key = new StringBuilder( 128 ); - if ( groupId != null ) - { - key.append( groupId ); - } - key.append( ':' ); - if ( artifactId != null ) - { - key.append( artifactId ); - } - key.append( ':' ); - key.append( ( type != null ) ? type : "jar" ); - if ( classifier != null && classifier.length() > 0 ) - { - key.append( ':' ); - key.append( classifier ); - } - return key.toString(); - } - - public void addExclusion( Exclusion exclusion ) - { - checkChildrenAllowed(); - this.exclusions.add( exclusion ); - } - - public List<Exclusion> getExclusions() - { - if ( isReference() ) - { - return getRef().getExclusions(); - } - return exclusions; - } - - private BuildException ambiguousCoords() - { - return new BuildException( "You must not specify both 'coords' and " - + "('groupId', 'artifactId', 'version', 'extension', 'classifier', 'scope')" ); - } - -}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/DependencyContainer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/DependencyContainer.java b/src/main/java/org/apache/maven/aether/internal/ant/types/DependencyContainer.java deleted file mode 100644 index 6cdc92a..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/DependencyContainer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.tools.ant.Task; - -/** - */ -public interface DependencyContainer -{ - - void validate( Task task ); - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Exclusion.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Exclusion.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Exclusion.java deleted file mode 100644 index 9b99f80..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Exclusion.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Exclusion - extends DataType -{ - - private static final String WILDCARD = "*"; - - private String groupId; - - private String artifactId; - - private String classifier; - - private String extension; - - protected Exclusion getRef() - { - return (Exclusion) getCheckedRef(); - } - - public void validate( Task task ) - { - if ( isReference() ) - { - getRef().validate( task ); - } - else - { - if ( groupId == null && artifactId == null && classifier == null && extension == null ) - { - throw new BuildException( "You must specify at least one of " - + "'groupId', 'artifactId', 'classifier' or 'extension'" ); - } - } - } - - public void setRefid( Reference ref ) - { - if ( groupId != null || artifactId != null || extension != null || classifier != null ) - { - throw tooManyAttributes(); - } - super.setRefid( ref ); - } - - public String getGroupId() - { - if ( isReference() ) - { - return getRef().getGroupId(); - } - return ( groupId != null ) ? groupId : WILDCARD; - } - - public void setGroupId( String groupId ) - { - checkAttributesAllowed(); - if ( this.groupId != null ) - { - throw ambiguousCoords(); - } - this.groupId = groupId; - } - - public String getArtifactId() - { - if ( isReference() ) - { - return getRef().getArtifactId(); - } - return ( artifactId != null ) ? artifactId : WILDCARD; - } - - public void setArtifactId( String artifactId ) - { - checkAttributesAllowed(); - if ( this.artifactId != null ) - { - throw ambiguousCoords(); - } - this.artifactId = artifactId; - } - - public String getClassifier() - { - if ( isReference() ) - { - return getRef().getClassifier(); - } - return ( classifier != null ) ? classifier : WILDCARD; - } - - public void setClassifier( String classifier ) - { - checkAttributesAllowed(); - if ( this.classifier != null ) - { - throw ambiguousCoords(); - } - this.classifier = classifier; - } - - public String getExtension() - { - if ( isReference() ) - { - return getRef().getExtension(); - } - return ( extension != null ) ? extension : WILDCARD; - } - - public void setExtension( String extension ) - { - checkAttributesAllowed(); - if ( this.extension != null ) - { - throw ambiguousCoords(); - } - this.extension = extension; - } - - public void setCoords( String coords ) - { - checkAttributesAllowed(); - if ( groupId != null || artifactId != null || extension != null || classifier != null ) - { - throw ambiguousCoords(); - } - Pattern p = Pattern.compile( "([^: ]+)(:([^: ]+)(:([^: ]+)(:([^: ]*))?)?)?" ); - Matcher m = p.matcher( coords ); - if ( !m.matches() ) - { - throw new BuildException( "Bad exclusion coordinates '" + coords - + "', expected format is <groupId>[:<artifactId>[:<extension>[:<classifier>]]]" ); - } - groupId = m.group( 1 ); - artifactId = m.group( 3 ); - if ( artifactId == null ) - { - artifactId = "*"; - } - extension = m.group( 5 ); - if ( extension == null ) - { - extension = "*"; - } - classifier = m.group( 7 ); - if ( classifier == null ) - { - classifier = "*"; - } - } - - private BuildException ambiguousCoords() - { - return new BuildException( "You must not specify both 'coords' and " - + "('groupId', 'artifactId', 'extension', 'classifier')" ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/LocalRepository.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/LocalRepository.java b/src/main/java/org/apache/maven/aether/internal/ant/types/LocalRepository.java deleted file mode 100644 index 9371aab..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/LocalRepository.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.aether.internal.ant.AntRepoSys; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class LocalRepository - extends DataType -{ - - private final Task task; - - private File dir; - - public LocalRepository() - { - this( null ); - } - - public LocalRepository( Task task ) - { - this.task = task; - } - - @Override - public void setProject( Project project ) - { - super.setProject( project ); - - if ( task == null ) - { - AntRepoSys.getInstance( project ).setLocalRepository( this ); - } - } - - protected LocalRepository getRef() - { - return (LocalRepository) getCheckedRef(); - } - - public void setRefid( Reference ref ) - { - if ( dir != null ) - { - throw tooManyAttributes(); - } - super.setRefid( ref ); - } - - public File getDir() - { - if ( isReference() ) - { - return getRef().getDir(); - } - return dir; - } - - public void setDir( File dir ) - { - checkAttributesAllowed(); - this.dir = dir; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Mirror.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Mirror.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Mirror.java deleted file mode 100644 index bbb19bb..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Mirror.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.aether.internal.ant.AntRepoSys; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Mirror - extends DataType -{ - - private String id; - - private String url; - - private String type; - - private String mirrorOf; - - private Authentication authentication; - - @Override - public void setProject( Project project ) - { - super.setProject( project ); - - AntRepoSys.getInstance( project ).addMirror( this ); - } - - protected Mirror getRef() - { - return (Mirror) getCheckedRef(); - } - - public void setRefid( Reference ref ) - { - if ( id != null || url != null || mirrorOf != null || type != null ) - { - throw tooManyAttributes(); - } - super.setRefid( ref ); - } - - public String getId() - { - if ( isReference() ) - { - return getRef().getId(); - } - return id; - } - - public void setId( String id ) - { - this.id = id; - } - - public String getUrl() - { - if ( isReference() ) - { - return getRef().getUrl(); - } - return url; - } - - public void setUrl( String url ) - { - checkAttributesAllowed(); - this.url = url; - } - - public String getType() - { - if ( isReference() ) - { - return getRef().getType(); - } - return ( type != null ) ? type : "default"; - } - - public void setType( String type ) - { - checkAttributesAllowed(); - this.type = type; - } - - public String getMirrorOf() - { - if ( isReference() ) - { - return getRef().getMirrorOf(); - } - return mirrorOf; - } - - public void setMirrorOf( String mirrorOf ) - { - checkAttributesAllowed(); - this.mirrorOf = mirrorOf; - } - - public void addAuthentication( Authentication authentication ) - { - checkChildrenAllowed(); - if ( this.authentication != null ) - { - throw new BuildException( "You must not specify multiple <authentication> elements" ); - } - this.authentication = authentication; - } - - public Authentication getAuthentication() - { - if ( isReference() ) - { - getRef().getAuthentication(); - } - return authentication; - } - - public void setAuthRef( Reference ref ) - { - if ( authentication == null ) - { - authentication = new Authentication(); - authentication.setProject( getProject() ); - } - authentication.setRefid( ref ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/ModelValueExtractor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/ModelValueExtractor.java b/src/main/java/org/apache/maven/aether/internal/ant/types/ModelValueExtractor.java deleted file mode 100644 index 73fed22..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/ModelValueExtractor.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.Model; -import org.apache.tools.ant.Project; -import org.codehaus.plexus.interpolation.reflection.ReflectionValueExtractor; - -/** - */ -class ModelValueExtractor -{ - - private static final String PREFIX_PROPERTIES = "properties."; - - private final String prefix; - - private final Project project; - - private final Model model; - - public ModelValueExtractor( String prefix, Model model, Project project ) - { - if ( model == null ) - { - throw new IllegalArgumentException( "reference to Maven POM has not been specified" ); - } - if ( project == null ) - { - throw new IllegalArgumentException( "reference to Ant project has not been specified" ); - } - if ( prefix == null || prefix.length() <= 0 ) - { - prefix = "pom."; - } - else if ( !prefix.endsWith( "." ) ) - { - prefix += '.'; - } - this.prefix = prefix; - this.model = model; - this.project = project; - } - - public Project getProject() - { - return project; - } - - public boolean isApplicable( String expression ) - { - return expression.startsWith( prefix ); - } - - public Object getValue( String expression ) - { - if ( expression.startsWith( prefix ) ) - { - String expr = expression.substring( prefix.length() ); - try - { - if ( expr.startsWith( PREFIX_PROPERTIES ) ) - { - String key = expr.substring( PREFIX_PROPERTIES.length() ); - return model.getProperties().getProperty( key ); - } - - return ReflectionValueExtractor.evaluate( expr, model, false ); - } - catch ( Exception e ) - { - project.log( "Could not retrieve '" + expression + "' from POM: " + e.getMessage(), e, Project.MSG_WARN ); - return null; - } - } - else - { - return null; - } - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Pom.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Pom.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Pom.java deleted file mode 100644 index eff8591..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Pom.java +++ /dev/null @@ -1,352 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.maven.aether.internal.ant.AntRepoSys; -import org.apache.maven.aether.internal.ant.ProjectWorkspaceReader; -import org.apache.maven.aether.internal.ant.tasks.RefTask; -import org.apache.maven.model.Model; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.PropertyHelper; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Pom - extends RefTask -{ - - private Model model; - - private String id; - - private File file; - - private String groupId; - - private String artifactId; - - private String version; - - private String packaging = "jar"; - - private RemoteRepositories remoteRepositories; - - private String coords; - - protected Pom getRef() - { - return (Pom) getCheckedRef(); - } - - public void validate() - { - if ( isReference() ) - { - getRef().validate(); - } - else - { - if ( file == null ) - { - if ( groupId == null ) - { - throw new BuildException( "You must specify the 'groupId' for the POM" ); - } - if ( artifactId == null ) - { - throw new BuildException( "You must specify the 'artifactId' for the POM" ); - } - if ( version == null ) - { - throw new BuildException( "You must specify the 'version' for the POM" ); - } - } - } - - } - - public void setRefid( Reference ref ) - { - if ( id != null || file != null || groupId != null || artifactId != null || version != null ) - { - throw tooManyAttributes(); - } - if ( remoteRepositories != null ) - { - throw noChildrenAllowed(); - } - super.setRefid( ref ); - } - - public void setId( String id ) - { - checkAttributesAllowed(); - this.id = id; - } - - public File getFile() - { - if ( isReference() ) - { - return getRef().getFile(); - } - return file; - } - - public void setFile( File file ) - { - checkAttributesAllowed(); - if ( groupId != null || artifactId != null || version != null ) - { - throw ambiguousSource(); - } - - this.file = file; - - } - - public String getGroupId() - { - if ( isReference() ) - { - return getRef().getGroupId(); - } - return groupId; - } - - public void setGroupId( String groupId ) - { - checkAttributesAllowed(); - if ( this.groupId != null ) - { - throw ambiguousCoords(); - } - if ( file != null ) - { - throw ambiguousSource(); - } - this.groupId = groupId; - } - - public String getArtifactId() - { - if ( isReference() ) - { - return getRef().getArtifactId(); - } - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - checkAttributesAllowed(); - if ( this.artifactId != null ) - { - throw ambiguousCoords(); - } - if ( file != null ) - { - throw ambiguousSource(); - } - this.artifactId = artifactId; - } - - public String getVersion() - { - if ( isReference() ) - { - return getRef().getVersion(); - } - return version; - } - - public void setVersion( String version ) - { - checkAttributesAllowed(); - if ( this.version != null ) - { - throw ambiguousCoords(); - } - if ( file != null ) - { - throw ambiguousSource(); - } - this.version = version; - } - - public String getCoords() - { - if ( isReference() ) - { - return getRef().getCoords(); - } - return coords; - } - - public void setCoords( String coords ) - { - checkAttributesAllowed(); - if ( file != null ) - { - throw ambiguousSource(); - } - if ( groupId != null || artifactId != null || version != null ) - { - throw ambiguousCoords(); - } - Pattern p = Pattern.compile( "([^: ]+):([^: ]+):([^: ]+)" ); - Matcher m = p.matcher( coords ); - if ( !m.matches() ) - { - throw new BuildException( "Bad POM coordinates, expected format is <groupId>:<artifactId>:<version>" ); - } - groupId = m.group( 1 ); - artifactId = m.group( 2 ); - version = m.group( 3 ); - } - - private BuildException ambiguousCoords() - { - return new BuildException( "You must not specify both 'coords' and ('groupId', 'artifactId', 'version')" ); - } - - private BuildException ambiguousSource() - { - return new BuildException( "You must not specify both 'file' and " - + "('coords', 'groupId', 'artifactId', 'version')" ); - } - - public String getPackaging() - { - if ( isReference() ) - { - return getRef().getPackaging(); - } - return packaging; - } - - public void setPackaging( String packaging ) - { - checkAttributesAllowed(); - if ( file != null ) - { - throw ambiguousSource(); - } - this.packaging = packaging; - } - - private RemoteRepositories getRemoteRepos() - { - if ( remoteRepositories == null ) - { - remoteRepositories = new RemoteRepositories(); - remoteRepositories.setProject( getProject() ); - } - return remoteRepositories; - } - - public void addRemoteRepo( RemoteRepository repository ) - { - getRemoteRepos().addRemoterepo( repository ); - } - - public void addRemoteRepos( RemoteRepositories repositories ) - { - getRemoteRepos().addRemoterepos( repositories ); - } - - public void setRemoteReposRef( Reference ref ) - { - RemoteRepositories repos = new RemoteRepositories(); - repos.setProject( getProject() ); - repos.setRefid( ref ); - getRemoteRepos().addRemoterepos( repos ); - } - - public Model getModel( Task task ) - { - if ( isReference() ) - { - return getRef().getModel( task ); - } - synchronized ( this ) - { - if ( model == null ) - { - if ( file != null ) - { - model = AntRepoSys.getInstance( getProject() ).loadModel( task, file, true, remoteRepositories ); - } - } - return model; - } - } - - @Override - public void execute() - { - validate(); - - if ( file != null && ( id == null || AntRepoSys.getInstance( getProject() ).getDefaultPom() == null ) ) - { - AntRepoSys.getInstance( getProject() ).setDefaultPom( this ); - } - - ProjectWorkspaceReader.getInstance().addPom( this ); - - Model model = getModel( this ); - - if ( model == null ) - { - coords = getGroupId() + ":" + getArtifactId() + ":" + getVersion(); - return; - } - - coords = model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getVersion(); - - ModelValueExtractor extractor = new ModelValueExtractor( id, model, getProject() ); - - PropertyHelper propHelper = PropertyHelper.getPropertyHelper( getProject() ); - - try - { - // Ant 1.8.0 delegate - PomPropertyEvaluator.register( extractor, propHelper ); - } - catch ( LinkageError e ) - { - // Ant 1.6 - 1.7.1 interceptor chaining - PomPropertyHelper.register( extractor, propHelper ); - } - - } - - public String toString() - { - return coords + " (" + super.toString() + ")"; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyEvaluator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyEvaluator.java b/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyEvaluator.java deleted file mode 100644 index 1097e76..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyEvaluator.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.tools.ant.PropertyHelper; -import org.apache.tools.ant.PropertyHelper.PropertyEvaluator; -import org.apache.tools.ant.property.NullReturn; - -/** - */ -class PomPropertyEvaluator - implements PropertyEvaluator -{ - - private final ModelValueExtractor extractor; - - public static void register( ModelValueExtractor extractor, PropertyHelper propertyHelper ) - { - propertyHelper.add( new PomPropertyEvaluator( extractor ) ); - } - - private PomPropertyEvaluator( ModelValueExtractor extractor ) - { - if ( extractor == null ) - { - throw new IllegalArgumentException( "no model value exractor specified" ); - } - this.extractor = extractor; - } - - public Object evaluate( String property, PropertyHelper propertyHelper ) - { - Object value = extractor.getValue( property ); - if ( value != null ) - { - return value; - } - else if ( extractor.isApplicable( property ) ) - { - return NullReturn.NULL; - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyHelper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyHelper.java b/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyHelper.java deleted file mode 100644 index 76af53b..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/PomPropertyHelper.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.tools.ant.PropertyHelper; - -/** - */ -@SuppressWarnings( "deprecation" ) -class PomPropertyHelper - extends PropertyHelper -{ - - private final ModelValueExtractor extractor; - - public static void register( ModelValueExtractor extractor, PropertyHelper propertyHelper ) - { - PomPropertyHelper helper = new PomPropertyHelper( extractor ); - helper.setNext( propertyHelper.getNext() ); - propertyHelper.setNext( helper ); - } - - public PomPropertyHelper( ModelValueExtractor extractor ) - { - if ( extractor == null ) - { - throw new IllegalArgumentException( "no model value exractor specified" ); - } - this.extractor = extractor; - setProject( extractor.getProject() ); - } - - @Override - public Object getPropertyHook( String ns, String name, boolean user ) - { - Object value = extractor.getValue( name ); - if ( value != null ) - { - return value; - } - else if ( extractor.isApplicable( name ) ) - { - return null; - } - return super.getPropertyHook( ns, name, user ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Proxy.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Proxy.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Proxy.java deleted file mode 100644 index 0ff671a..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Proxy.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.aether.internal.ant.AntRepoSys; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Proxy - extends DataType -{ - - private String host; - - private int port; - - private String type; - - private String nonProxyHosts; - - private Authentication authentication; - - @Override - public void setProject( Project project ) - { - super.setProject( project ); - - AntRepoSys.getInstance( project ).addProxy( this ); - } - - protected Proxy getRef() - { - return (Proxy) getCheckedRef(); - } - - public void setRefid( Reference ref ) - { - if ( host != null || port != 0 || type != null || nonProxyHosts != null ) - { - throw tooManyAttributes(); - } - if ( authentication != null ) - { - throw noChildrenAllowed(); - } - super.setRefid( ref ); - } - - public String getHost() - { - if ( isReference() ) - { - return getRef().getHost(); - } - return host; - } - - public void setHost( String host ) - { - checkAttributesAllowed(); - this.host = host; - } - - public int getPort() - { - if ( isReference() ) - { - return getRef().getPort(); - } - return port; - } - - public void setPort( int port ) - { - checkAttributesAllowed(); - if ( port <= 0 || port > 0xFFFF ) - { - throw new BuildException( "The port number must be within the range 1 - 65535" ); - } - this.port = port; - } - - public String getType() - { - if ( isReference() ) - { - return getRef().getType(); - } - return type; - } - - public void setType( String type ) - { - checkAttributesAllowed(); - this.type = type; - } - - public String getNonProxyHosts() - { - if ( isReference() ) - { - return getRef().getNonProxyHosts(); - } - return nonProxyHosts; - } - - public void setNonProxyHosts( String nonProxyHosts ) - { - checkAttributesAllowed(); - this.nonProxyHosts = nonProxyHosts; - } - - public Authentication getAuthentication() - { - if ( isReference() ) - { - return getRef().getAuthentication(); - } - return authentication; - } - - public void addAuthentication( Authentication authentication ) - { - checkChildrenAllowed(); - if ( this.authentication != null ) - { - throw new BuildException( "You must not specify multiple <authentication> elements" ); - } - this.authentication = authentication; - } - - public void setAuthRef( Reference ref ) - { - if ( authentication == null ) - { - authentication = new Authentication(); - authentication.setProject( getProject() ); - } - authentication.setRefid( ref ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositories.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositories.java b/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositories.java deleted file mode 100644 index 063a3b6..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositories.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.List; - -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class RemoteRepositories - extends DataType - implements RemoteRepositoryContainer -{ - - private List<RemoteRepositoryContainer> containers = new ArrayList<RemoteRepositoryContainer>(); - - protected RemoteRepositories getRef() - { - return (RemoteRepositories) getCheckedRef(); - } - - public void validate( Task task ) - { - if ( isReference() ) - { - getRef().validate( task ); - } - else - { - for ( RemoteRepositoryContainer container : containers ) - { - container.validate( task ); - } - } - } - - public void setRefid( Reference ref ) - { - if ( !containers.isEmpty() ) - { - throw noChildrenAllowed(); - } - super.setRefid( ref ); - } - - public void addRemoterepo( RemoteRepository repository ) - { - checkChildrenAllowed(); - containers.add( repository ); - } - - public void addRemoterepos( RemoteRepositories repositories ) - { - checkChildrenAllowed(); - if ( repositories == this ) - { - throw circularReference(); - } - containers.add( repositories ); - } - - public List<RemoteRepository> getRepositories() - { - if ( isReference() ) - { - return getRef().getRepositories(); - } - List<RemoteRepository> repos = new ArrayList<RemoteRepository>(); - for ( RemoteRepositoryContainer container : containers ) - { - repos.addAll( container.getRepositories() ); - } - return repos; - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepository.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepository.java b/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepository.java deleted file mode 100644 index 4720004..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepository.java +++ /dev/null @@ -1,351 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.Collections; -import java.util.List; - -import org.apache.maven.aether.internal.ant.AntRepoSys; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; -import org.eclipse.aether.repository.RepositoryPolicy; - -/** - */ -public class RemoteRepository - extends DataType - implements RemoteRepositoryContainer -{ - - private String id; - - private String url; - - private String type; - - private Policy releasePolicy; - - private Policy snapshotPolicy; - - private boolean releases = true; - - private boolean snapshots = false; - - private String checksums; - - private String updates; - - private Authentication authentication; - - @Override - public void setProject( Project project ) - { - super.setProject( project ); - - // NOTE: Just trigger side-effect of default initialization before this type potentially overrides central - AntRepoSys.getInstance( project ); - } - - protected RemoteRepository getRef() - { - return (RemoteRepository) getCheckedRef(); - } - - public void validate( Task task ) - { - if ( isReference() ) - { - getRef().validate( task ); - } - else - { - if ( url == null || url.length() <= 0 ) - { - throw new BuildException( "You must specify the 'url' for a remote repository" ); - } - if ( id == null || id.length() <= 0 ) - { - throw new BuildException( "You must specify the 'id' for a remote repository" ); - } - } - } - - public void setRefid( Reference ref ) - { - if ( id != null || url != null || type != null || checksums != null || updates != null ) - { - throw tooManyAttributes(); - } - if ( releasePolicy != null || snapshotPolicy != null || authentication != null ) - { - throw noChildrenAllowed(); - } - super.setRefid( ref ); - } - - public String getId() - { - if ( isReference() ) - { - return getRef().getId(); - } - return id; - } - - public void setId( String id ) - { - this.id = id; - } - - public String getUrl() - { - if ( isReference() ) - { - return getRef().getUrl(); - } - return url; - } - - public void setUrl( String url ) - { - checkAttributesAllowed(); - this.url = url; - } - - public String getType() - { - if ( isReference() ) - { - return getRef().getType(); - } - return ( type != null ) ? type : "default"; - } - - public void setType( String type ) - { - checkAttributesAllowed(); - this.type = type; - } - - public Policy getReleasePolicy() - { - if ( isReference() ) - { - return getRef().getReleasePolicy(); - } - return releasePolicy; - } - - public void addReleases( Policy policy ) - { - checkChildrenAllowed(); - if ( this.releasePolicy != null ) - { - throw new BuildException( "You must not specify multiple <releases> elements" ); - } - this.releasePolicy = policy; - } - - public Policy getSnapshotPolicy() - { - if ( isReference() ) - { - return getRef().getSnapshotPolicy(); - } - return snapshotPolicy; - } - - public void addSnapshots( Policy policy ) - { - checkChildrenAllowed(); - if ( this.snapshotPolicy != null ) - { - throw new BuildException( "You must not specify multiple <snapshots> elements" ); - } - this.snapshotPolicy = policy; - } - - public boolean isReleases() - { - if ( isReference() ) - { - return getRef().isReleases(); - } - return releases; - } - - public void setReleases( boolean releases ) - { - checkAttributesAllowed(); - this.releases = releases; - } - - public boolean isSnapshots() - { - if ( isReference() ) - { - return getRef().isSnapshots(); - } - return snapshots; - } - - public void setSnapshots( boolean snapshots ) - { - checkAttributesAllowed(); - this.snapshots = snapshots; - } - - public String getUpdates() - { - if ( isReference() ) - { - return getRef().getUpdates(); - } - return ( updates != null ) ? updates : RepositoryPolicy.UPDATE_POLICY_DAILY; - } - - public void setUpdates( String updates ) - { - checkAttributesAllowed(); - checkUpdates( updates ); - this.updates = updates; - } - - protected static void checkUpdates( String updates ) - { - if ( !RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( updates ) - && !RepositoryPolicy.UPDATE_POLICY_DAILY.equals( updates ) - && !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( updates ) - && !updates.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) ) - { - throw new BuildException( "'" + updates + "' is not a permitted update policy" ); - } - } - - public String getChecksums() - { - if ( isReference() ) - { - return getRef().getChecksums(); - } - return ( checksums != null ) ? checksums : RepositoryPolicy.CHECKSUM_POLICY_WARN; - } - - public void setChecksums( String checksums ) - { - checkAttributesAllowed(); - checkChecksums( checksums ); - this.checksums = checksums; - } - - protected static void checkChecksums( String checksums ) - { - if ( !RepositoryPolicy.CHECKSUM_POLICY_FAIL.equals( checksums ) - && !RepositoryPolicy.CHECKSUM_POLICY_WARN.equals( checksums ) - && !RepositoryPolicy.CHECKSUM_POLICY_IGNORE.equals( checksums ) ) - { - throw new BuildException( "'" + checksums + "' is not a permitted checksum policy" ); - } - } - - public Authentication getAuthentication() - { - if ( isReference() ) - { - return getRef().getAuthentication(); - } - return authentication; - } - - public void addAuthentication( Authentication authentication ) - { - checkChildrenAllowed(); - if ( this.authentication != null ) - { - throw new BuildException( "You must not specify multiple <authentication> elements" ); - } - this.authentication = authentication; - } - - public void setAuthRef( Reference ref ) - { - checkAttributesAllowed(); - if ( authentication == null ) - { - authentication = new Authentication(); - authentication.setProject( getProject() ); - } - authentication.setRefid( ref ); - } - - public List<RemoteRepository> getRepositories() - { - return Collections.singletonList( this ); - } - - /** - */ - public static class Policy - { - - private boolean enabled = true; - - private String checksumPolicy; - - private String updatePolicy; - - public boolean isEnabled() - { - return enabled; - } - - public void setEnabled( boolean enabled ) - { - this.enabled = enabled; - } - - public String getChecksums() - { - return checksumPolicy; - } - - public void setChecksums( String checksumPolicy ) - { - checkChecksums( checksumPolicy ); - this.checksumPolicy = checksumPolicy; - } - - public String getUpdates() - { - return updatePolicy; - } - - public void setUpdates( String updatePolicy ) - { - checkUpdates( updatePolicy ); - this.updatePolicy = updatePolicy; - } - - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositoryContainer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositoryContainer.java b/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositoryContainer.java deleted file mode 100644 index 488ffb6..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/RemoteRepositoryContainer.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.tools.ant.Task; - -/** - */ -public interface RemoteRepositoryContainer -{ - - void validate( Task task ); - - List<RemoteRepository> getRepositories(); - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/aether/internal/ant/types/Settings.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/aether/internal/ant/types/Settings.java b/src/main/java/org/apache/maven/aether/internal/ant/types/Settings.java deleted file mode 100644 index 85190b1..0000000 --- a/src/main/java/org/apache/maven/aether/internal/ant/types/Settings.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.apache.maven.aether.internal.ant.types; - -/* - * 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.aether.internal.ant.AntRepoSys; -import org.apache.tools.ant.types.DataType; -import org.apache.tools.ant.types.Reference; - -/** - */ -public class Settings - extends DataType -{ - - private File file; - - private File globalFile; - - protected Settings getRef() - { - return (Settings) getCheckedRef(); - } - - public void setRefid( Reference ref ) - { - if ( file != null || globalFile != null ) - { - throw tooManyAttributes(); - } - super.setRefid( ref ); - } - - public File getFile() - { - if ( isReference() ) - { - return getRef().getFile(); - } - return file; - } - - public void setFile( File file ) - { - checkAttributesAllowed(); - this.file = file; - - AntRepoSys.getInstance( getProject() ).setUserSettings( file ); - } - - public File getGlobalFile() - { - if ( isReference() ) - { - return getRef().getFile(); - } - return globalFile; - } - - public void setGlobalFile( File globalFile ) - { - checkAttributesAllowed(); - this.globalFile = globalFile; - - AntRepoSys.getInstance( getProject() ).setGlobalSettings( globalFile ); - } - -} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java b/src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java new file mode 100644 index 0000000..6b59f90 --- /dev/null +++ b/src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java @@ -0,0 +1,83 @@ +package org.apache.maven.resolver.internal.ant; + +/* + * 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.resolver.internal.ant.types.RemoteRepositories; +import org.apache.tools.ant.Project; + +class AetherUtils +{ + + public static File findGlobalSettings( Project project ) + { + File file = new File( new File( project.getProperty( "ant.home" ), "etc" ), Names.SETTINGS_XML ); + if ( file.isFile() ) + { + return file; + } + else + { + String mavenHome = getMavenHome( project ); + if ( mavenHome != null ) + { + return new File( new File( mavenHome, "conf" ), Names.SETTINGS_XML ); + } + } + + return null; + } + + public static String getMavenHome( Project project ) + { + String mavenHome = project.getProperty( "maven.home" ); + if ( mavenHome != null ) + { + return mavenHome; + } + return System.getenv( "M2_HOME" ); + } + + public static File findUserSettings( Project project ) + { + File userHome = new File( project.getProperty( "user.home" ) ); + File file = new File( new File( userHome, ".ant" ), Names.SETTINGS_XML ); + if ( file.isFile() ) + { + return file; + } + else + { + return new File( new File( userHome, ".m2" ), Names.SETTINGS_XML ); + } + } + + public static RemoteRepositories getDefaultRepositories( Project project ) + { + Object obj = project.getReference( Names.ID_DEFAULT_REPOS ); + if ( obj instanceof RemoteRepositories ) + { + return (RemoteRepositories) obj; + } + return null; + } + +} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/resolver/internal/ant/AntLogger.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/resolver/internal/ant/AntLogger.java b/src/main/java/org/apache/maven/resolver/internal/ant/AntLogger.java new file mode 100644 index 0000000..711d653 --- /dev/null +++ b/src/main/java/org/apache/maven/resolver/internal/ant/AntLogger.java @@ -0,0 +1,68 @@ +package org.apache.maven.resolver.internal.ant; + +/* + * 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.tools.ant.Project; +import org.eclipse.aether.spi.log.Logger; + +/** + */ +class AntLogger + implements Logger +{ + + private Project project; + + public AntLogger( Project project ) + { + this.project = project; + } + + public void debug( String msg ) + { + project.log( msg, Project.MSG_DEBUG ); + } + + public void debug( String msg, Throwable error ) + { + project.log( msg, error, Project.MSG_DEBUG ); + } + + public boolean isDebugEnabled() + { + return true; + } + + public boolean isWarnEnabled() + { + return true; + } + + public void warn( String msg ) + { + project.log( msg, Project.MSG_WARN ); + } + + public void warn( String msg, Throwable error ) + { + project.log( msg, error, Project.MSG_WARN ); + } + +} http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/b5f1ab9c/src/main/java/org/apache/maven/resolver/internal/ant/AntModelResolver.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/maven/resolver/internal/ant/AntModelResolver.java b/src/main/java/org/apache/maven/resolver/internal/ant/AntModelResolver.java new file mode 100644 index 0000000..83311fb --- /dev/null +++ b/src/main/java/org/apache/maven/resolver/internal/ant/AntModelResolver.java @@ -0,0 +1,157 @@ +package org.apache.maven.resolver.internal.ant; + +/* + * 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.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.maven.model.Repository; +import org.apache.maven.model.building.FileModelSource; +import org.apache.maven.model.building.ModelSource; +import org.apache.maven.model.resolution.InvalidRepositoryException; +import org.apache.maven.model.resolution.ModelResolver; +import org.apache.maven.model.resolution.UnresolvableModelException; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.repository.RepositoryPolicy; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; + +/** + * A model resolver to assist building of dependency POMs. This resolver gives priority to those repositories that have + * been initially specified and repositories discovered in dependency POMs are recessively merged into the search chain. + * + */ +class AntModelResolver + implements ModelResolver +{ + + private final RepositorySystemSession session; + + private final String context; + + private List<org.eclipse.aether.repository.RemoteRepository> repositories; + + private final RepositorySystem repoSys; + + private final RemoteRepositoryManager remoteRepositoryManager; + + private final Set<String> repositoryIds; + + public AntModelResolver( RepositorySystemSession session, String context, RepositorySystem repoSys, + RemoteRepositoryManager remoteRepositoryManager, List<RemoteRepository> repositories ) + { + this.session = session; + this.context = context; + this.repoSys = repoSys; + this.remoteRepositoryManager = remoteRepositoryManager; + this.repositories = repositories; + this.repositoryIds = new HashSet<String>(); + } + + private AntModelResolver( AntModelResolver original ) + { + this.session = original.session; + this.context = original.context; + this.repoSys = original.repoSys; + this.remoteRepositoryManager = original.remoteRepositoryManager; + this.repositories = original.repositories; + this.repositoryIds = new HashSet<String>( original.repositoryIds ); + } + + public void addRepository( Repository repository ) + throws InvalidRepositoryException + { + if ( !repositoryIds.add( repository.getId() ) ) + { + return; + } + + List<RemoteRepository> newRepositories = Collections.singletonList( convert( repository ) ); + + this.repositories = + remoteRepositoryManager.aggregateRepositories( session, repositories, newRepositories, true ); + } + + static RemoteRepository convert( Repository repository ) + { + RemoteRepository.Builder builder = + new RemoteRepository.Builder( repository.getId(), repository.getLayout(), repository.getUrl() ); + builder.setSnapshotPolicy( convert( repository.getSnapshots() ) ); + builder.setReleasePolicy( convert( repository.getReleases() ) ); + return builder.build(); + } + + private static RepositoryPolicy convert( org.apache.maven.model.RepositoryPolicy policy ) + { + boolean enabled = true; + String checksums = RepositoryPolicy.CHECKSUM_POLICY_WARN; + String updates = RepositoryPolicy.UPDATE_POLICY_DAILY; + + if ( policy != null ) + { + enabled = policy.isEnabled(); + if ( policy.getUpdatePolicy() != null ) + { + updates = policy.getUpdatePolicy(); + } + if ( policy.getChecksumPolicy() != null ) + { + checksums = policy.getChecksumPolicy(); + } + } + + return new RepositoryPolicy( enabled, updates, checksums ); + } + + public ModelResolver newCopy() + { + return new AntModelResolver( this ); + } + + public ModelSource resolveModel( String groupId, String artifactId, String version ) + throws UnresolvableModelException + { + Artifact pomArtifact = new DefaultArtifact( groupId, artifactId, "", "pom", version ); + + try + { + ArtifactRequest request = new ArtifactRequest( pomArtifact, repositories, context ); + pomArtifact = repoSys.resolveArtifact( session, request ).getArtifact(); + } + catch ( ArtifactResolutionException e ) + { + throw new UnresolvableModelException( "Failed to resolve POM for " + groupId + ":" + artifactId + ":" + + version + " due to " + e.getMessage(), groupId, artifactId, version, e ); + } + + File pomFile = pomArtifact.getFile(); + + return new FileModelSource( pomFile ); + } + +}
