You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mm...@apache.org on 2017/11/09 03:19:37 UTC
[6/9] maven-resolver git commit: moved ant tasks into subfolder
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyEvaluator.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyEvaluator.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyEvaluator.java
new file mode 100644
index 0000000..1b76bfd
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyEvaluator.java
@@ -0,0 +1,62 @@
+package org.apache.maven.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyHelper.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyHelper.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyHelper.java
new file mode 100644
index 0000000..5ec23ec
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/PomPropertyHelper.java
@@ -0,0 +1,65 @@
+package org.apache.maven.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Proxy.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Proxy.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Proxy.java
new file mode 100644
index 0000000..6116c8e
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Proxy.java
@@ -0,0 +1,163 @@
+package org.apache.maven.resolver.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.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositories.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositories.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositories.java
new file mode 100644
index 0000000..0b90877
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositories.java
@@ -0,0 +1,97 @@
+package org.apache.maven.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepository.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepository.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepository.java
new file mode 100644
index 0000000..aabefd2
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepository.java
@@ -0,0 +1,351 @@
+package org.apache.maven.resolver.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.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositoryContainer.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositoryContainer.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositoryContainer.java
new file mode 100644
index 0000000..ab84a98
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/RemoteRepositoryContainer.java
@@ -0,0 +1,35 @@
+package org.apache.maven.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Settings.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Settings.java b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Settings.java
new file mode 100644
index 0000000..5c77c43
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/java/org/apache/maven/resolver/internal/ant/types/Settings.java
@@ -0,0 +1,86 @@
+package org.apache.maven.resolver.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.resolver.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/a088cdfc/maven-resolver-ant-tasks/src/main/resources/org/apache/maven/resolver/ant/antlib.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/main/resources/org/apache/maven/resolver/ant/antlib.xml b/maven-resolver-ant-tasks/src/main/resources/org/apache/maven/resolver/ant/antlib.xml
new file mode 100644
index 0000000..0e47b30
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/main/resources/org/apache/maven/resolver/ant/antlib.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<antlib>
+
+ <typedef name="authentication" classname="org.apache.maven.resolver.internal.ant.types.Authentication"/>
+ <typedef name="proxy" classname="org.apache.maven.resolver.internal.ant.types.Proxy"/>
+ <typedef name="mirror" classname="org.apache.maven.resolver.internal.ant.types.Mirror"/>
+ <typedef name="localrepo" classname="org.apache.maven.resolver.internal.ant.types.LocalRepository"/>
+ <typedef name="remoterepo" classname="org.apache.maven.resolver.internal.ant.types.RemoteRepository"/>
+ <typedef name="remoterepos" classname="org.apache.maven.resolver.internal.ant.types.RemoteRepositories"/>
+ <typedef name="dependency" classname="org.apache.maven.resolver.internal.ant.types.Dependency"/>
+ <typedef name="dependencies" classname="org.apache.maven.resolver.internal.ant.types.Dependencies"/>
+ <typedef name="artifact" classname="org.apache.maven.resolver.internal.ant.types.Artifact"/>
+ <typedef name="artifacts" classname="org.apache.maven.resolver.internal.ant.types.Artifacts"/>
+ <typedef name="settings" classname="org.apache.maven.resolver.internal.ant.types.Settings"/>
+
+ <taskdef name="resolve" classname="org.apache.maven.resolver.internal.ant.tasks.Resolve"/>
+ <taskdef name="install" classname="org.apache.maven.resolver.internal.ant.tasks.Install"/>
+ <taskdef name="deploy" classname="org.apache.maven.resolver.internal.ant.tasks.Deploy"/>
+ <taskdef name="pom" classname="org.apache.maven.resolver.internal.ant.types.Pom"/>
+
+</antlib>
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/site/markdown/index.md.vm
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/site/markdown/index.md.vm b/maven-resolver-ant-tasks/src/site/markdown/index.md.vm
new file mode 100644
index 0000000..21d7689
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/site/markdown/index.md.vm
@@ -0,0 +1 @@
+#include( "../../../README.md" )
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/site/resources/download.cgi
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/site/resources/download.cgi b/maven-resolver-ant-tasks/src/site/resources/download.cgi
new file mode 100644
index 0000000..1b178d2
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/site/resources/download.cgi
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# 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.
+#
+# Just call the standard mirrors.cgi script. It will use download.html
+# as the input template.
+exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/site/site.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/site/site.xml b/maven-resolver-ant-tasks/src/site/site.xml
new file mode 100644
index 0000000..6ba57dc
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/site/site.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0 http://maven.apache.org/xsd/decoration-1.1.0.xsd"
+ name="Maven Resolver Ant Tasks">
+
+ <body>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="JavaDocs" href="apidocs/index.html"/>
+ <item name="Source Xref" href="xref/index.html"/>
+ <!--item name="FAQ" href="faq.html"/-->
+ <item name="License" href="http://www.apache.org/licenses/"/>
+ <item name="Download" href="download.html"/>
+ </menu>
+ <menu name="See Also">
+ <item name="Maven Artifact Resolver" href="https://maven.apache.org/resolver/"/>
+ <item name="Maven Artifact Resolver Provider" href="https://maven.apache.org/ref/current/maven-resolver-provider/"/>
+ </menu>
+
+ <menu ref="reports"/>
+ </body>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/site/xdoc/download.xml.vm
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/site/xdoc/download.xml.vm b/maven-resolver-ant-tasks/src/site/xdoc/download.xml.vm
new file mode 100644
index 0000000..b37071a
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/site/xdoc/download.xml.vm
@@ -0,0 +1,126 @@
+<?xml version="1.0"?>
+
+<!--
+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.
+-->
+
+<document>
+ <properties>
+ <title>Download ${project.name} Source</title>
+ </properties>
+ <body>
+ <section name="Download ${project.name} ${project.version} Source">
+
+ <p>${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build
+ ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.</p>
+
+ <p>You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24
+ hours to reach all mirrors.<p/>
+
+ <p>In order to guard against corrupted downloads/installations, it is highly recommended to
+ <a href="http://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a>
+ of the release bundles against the public <a href="http://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
+ developers.</p>
+
+ <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
+
+ <p></p>We <b>strongly</b> encourage our users to configure a Maven repository mirror closer to their location, please read <a href="/guides/mini/guide-mirror-settings.html">How to Use Mirrors for Repositories</a>.</p>
+
+ <a name="mirror"/>
+ <subsection name="Mirror">
+
+ <p>
+ [if-any logo]
+ <a href="[link]">
+ <img align="right" src="[logo]" border="0"
+ alt="logo"/>
+ </a>
+ [end]
+ The currently selected mirror is
+ <b>[preferred]</b>.
+ If you encounter a problem with this mirror,
+ please select another mirror.
+ If all mirrors are failing, there are
+ <i>backup</i>
+ mirrors
+ (at the end of the mirrors list) that should be available.
+ </p>
+
+ <form action="[location]" method="get" id="SelectMirror">
+ Other mirrors:
+ <select name="Preferred">
+ [if-any http]
+ [for http]
+ <option value="[http]">[http]</option>
+ [end]
+ [end]
+ [if-any ftp]
+ [for ftp]
+ <option value="[ftp]">[ftp]</option>
+ [end]
+ [end]
+ [if-any backup]
+ [for backup]
+ <option value="[backup]">[backup] (backup)</option>
+ [end]
+ [end]
+ </select>
+ <input type="submit" value="Change"/>
+ </form>
+
+ <p>
+ You may also consult the
+ <a href="http://www.apache.org/mirrors/">complete list of
+ mirrors.</a>
+ </p>
+
+ </subsection>
+
+ <subsection name="${project.name} ${project.version}">
+
+ <p>This is the current stable version of ${project.name}.</p>
+
+ <table>
+ <thead>
+ <tr>
+ <th></th>
+ <th>Link</th>
+ <th>Checksum</th>
+ <th>Signature</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>${project.name} ${project.version} (Source zip)</td>
+ <td><a href="[preferred]maven/resolver/${project.artifactId}-${project.version}-source-release.zip">maven/resolver/${project.artifactId}-${project.version}-source-release.zip</a></td>
+ <td><a href="http://www.apache.org/dist/maven/resolver/${project.artifactId}-${project.version}-source-release.zip.md5">maven/resolver/${project.artifactId}-${project.version}-source-release.zip.md5</a></td>
+ <td><a href="http://www.apache.org/dist/maven/resolver/${project.artifactId}-${project.version}-source-release.zip.asc">maven/resolver/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
+ </tr>
+ </tbody>
+ </table>
+ </subsection>
+
+ <subsection name="Previous Versions">
+
+ <p>Older non-recommended releases can be found on our <a href="http://archive.apache.org/dist/maven/resolver/">archive site</a>.</p>
+
+ </subsection>
+ </section>
+ </body>
+</document>
+
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
new file mode 100644
index 0000000..aaf73da
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
@@ -0,0 +1,124 @@
+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.io.PrintStream;
+
+import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileTest;
+import org.apache.tools.ant.DefaultLogger;
+import org.apache.tools.ant.Project;
+import org.eclipse.aether.internal.test.util.TestFileUtils;
+
+public abstract class AntBuildsTest
+ extends BuildFileTest
+{
+
+ private static final File BASE_DIR;
+
+ protected static final File BUILD_DIR;
+
+ static
+ {
+ BASE_DIR = new File( "" ).getAbsoluteFile();
+ BUILD_DIR = new File( BASE_DIR, "target/ant" );
+ }
+
+ protected File projectDir;
+
+ protected File localRepoDir;
+
+ protected File distRepoDir;
+
+ protected String getProjectDirName()
+ {
+ String name = getClass().getSimpleName();
+ if ( name.endsWith( "Test" ) )
+ {
+ name = name.substring( 0, name.length() - 4 );
+ }
+ return name;
+ }
+
+ protected void setUpProperties()
+ throws Exception
+ {
+ // hook for subclasses to set further system properties for the project to pick up
+ }
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ TestFileUtils.deleteFile( BUILD_DIR );
+
+ projectDir = new File( new File( BASE_DIR, "src/test/resources/ant" ), getProjectDirName() );
+ localRepoDir = new File( BUILD_DIR, "local-repo" );
+ distRepoDir = new File( BUILD_DIR, "dist-repo" );
+
+ System.setProperty( "project.dir", projectDir.getAbsolutePath() );
+ System.setProperty( "build.dir", BUILD_DIR.getAbsolutePath() );
+ System.setProperty( "maven.repo.local", localRepoDir.getAbsolutePath() );
+ System.setProperty( "project.distrepo.url", distRepoDir.toURI().toString() );
+ setUpProperties();
+
+ configureProject( new File( projectDir, "ant.xml" ).getAbsolutePath(), Project.MSG_VERBOSE );
+ }
+
+ @Override
+ protected void tearDown()
+ throws Exception
+ {
+ try
+ {
+ ProjectWorkspaceReader.dropInstance();
+ TestFileUtils.deleteFile( BUILD_DIR );
+ }
+ finally
+ {
+ super.tearDown();
+ }
+ }
+
+ @Override
+ public void configureProject( String filename, int logLevel )
+ throws BuildException
+ {
+ super.configureProject( filename, logLevel );
+ DefaultLogger logger = new DefaultLogger()
+ {
+ @Override
+ protected void printMessage( String message, PrintStream stream, int priority )
+ {
+ message = System.currentTimeMillis() + " " + message;
+ super.printMessage( message, stream, priority );
+ }
+ };
+ logger.setMessageOutputLevel( logLevel );
+ logger.setOutputPrintStream( System.out );
+ logger.setErrorPrintStream( System.err );
+ getProject().addBuildListener( logger );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/DeployTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/DeployTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/DeployTest.java
new file mode 100644
index 0000000..203bdba
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/DeployTest.java
@@ -0,0 +1,91 @@
+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 static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.util.Arrays;
+
+/*
+ * still missing:
+ * - deploy snapshots/releases into correct repos
+ */
+public class DeployTest
+ extends AntBuildsTest
+{
+
+ public void testDeployGlobalPom()
+ {
+ long min = System.currentTimeMillis();
+ executeTarget( "testDeployGlobalPom" );
+ long max = System.currentTimeMillis();
+
+ assertLogContaining( "Uploading" );
+
+ assertUpdatedFile( min, max, distRepoDir, "test/dummy/0.1-SNAPSHOT/maven-metadata.xml" );
+ }
+
+ public void testDeployOverrideGlobalPom()
+ {
+ long min = System.currentTimeMillis();
+ executeTarget( "testDeployOverrideGlobalPom" );
+ long max = System.currentTimeMillis();
+
+ assertLogContaining( "Uploading" );
+
+ assertUpdatedFile( min, max, distRepoDir, "test/other/0.1-SNAPSHOT/maven-metadata.xml" );
+ }
+
+ public void testDeployOverrideGlobalPomByRef()
+ {
+ long min = System.currentTimeMillis();
+ executeTarget( "testDeployOverrideGlobalPomByRef" );
+ long max = System.currentTimeMillis();
+
+ assertLogContaining( "Uploading" );
+
+ assertUpdatedFile( min, max, distRepoDir, "test/dummy/0.1-SNAPSHOT/maven-metadata.xml" );
+ assertUpdatedFile( min, max, distRepoDir, "test/other/0.1-SNAPSHOT/maven-metadata.xml" );
+ }
+
+ public void testDeployAttachedArtifact()
+ {
+ executeTarget( "testDeployAttachedArtifact" );
+
+ assertLogContaining( "Uploading" );
+
+ File dir = new File(distRepoDir, "test/dummy/0.1-SNAPSHOT/" );
+ String[] files = dir.list();
+ assertThat( "attached artifact not found: " + Arrays.toString( files ), files,
+ hasItemInArray( endsWith( "-ant.xml" ) ) );
+ }
+
+ private void assertUpdatedFile( long min, long max, File repoPath, String path )
+ {
+ File file = new File( repoPath, path );
+ min = (min / 1000) * 1000;
+ max = ((max + 999) / 1000) * 1000;
+ assertThat( "File does not exist in default repo: " + file.getAbsolutePath(), file.exists() );
+ assertThat( "Files were not updated for 1s before/after timestamp", file.lastModified(),
+ allOf( greaterThanOrEqualTo( min ), lessThanOrEqualTo( max ) ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/InstallTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/InstallTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/InstallTest.java
new file mode 100644
index 0000000..bd3fcaa
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/InstallTest.java
@@ -0,0 +1,98 @@
+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 static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.io.IOException;
+
+public class InstallTest
+ extends AntBuildsTest
+{
+
+ public void testInstallGlobalPom()
+ {
+ executeTarget( "testInstallGlobalPom" );
+ long tstamp = System.currentTimeMillis();
+
+ assertLogContaining( "Installing" );
+
+ assertUpdatedFile( tstamp, localRepoDir, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT.pom" );
+ }
+
+ public void testInstallOverrideGlobalPom()
+ {
+ executeTarget( "testInstallOverrideGlobalPom" );
+ long tstamp = System.currentTimeMillis();
+
+ assertLogContaining( "Installing" );
+
+ assertUpdatedFile( tstamp, localRepoDir, "test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
+ }
+
+ public void testInstallOverrideGlobalPomByRef()
+ {
+ long tstamp = System.currentTimeMillis();
+ executeTarget( "testInstallOverrideGlobalPomByRef" );
+
+ assertLogContaining( "Installing" );
+
+ assertUpdatedFile( tstamp, localRepoDir, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT.pom" );
+ assertUpdatedFile( tstamp, localRepoDir, "test/other/0.1-SNAPSHOT/other-0.1-SNAPSHOT.pom" );
+ }
+
+ public void testDefaultRepo()
+ {
+ executeTarget( "testDefaultRepo" );
+ long tstamp = System.currentTimeMillis();
+
+ assertLogContaining( "Installing" );
+
+ assertUpdatedFile( tstamp, localRepoDir, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT.pom" );
+ assertUpdatedFile( tstamp, localRepoDir, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT-ant.xml" );
+ }
+
+ public void testCustomRepo()
+ throws IOException
+ {
+ File repoPath = new File( BUILD_DIR, "local-repo-custom" );
+
+ executeTarget( "testCustomRepo" );
+ long tstamp = System.currentTimeMillis();
+
+ System.out.println( getLog() );
+ assertLogContaining( "Installing" );
+
+ assertUpdatedFile( tstamp, repoPath, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT.pom" );
+ assertUpdatedFile( tstamp, repoPath, "test/dummy/0.1-SNAPSHOT/dummy-0.1-SNAPSHOT-ant.xml" );
+ }
+
+ private void assertUpdatedFile( long tstamp, File repoPath, String path )
+ {
+ File file = new File( repoPath, path );
+ assertThat( "File does not exist in default repo: " + file.getAbsolutePath(), file.exists() );
+ assertThat( "Files were not updated for 1s before/after timestamp",
+ file.lastModified(),
+ allOf( greaterThanOrEqualTo( ( ( tstamp - 500 ) / 1000 ) * 1000 ),
+ lessThanOrEqualTo( tstamp + 2000 ) ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
new file mode 100644
index 0000000..0b7dfa3
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
@@ -0,0 +1,124 @@
+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 static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+
+import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
+import org.apache.maven.resolver.internal.ant.types.Pom;
+import org.apache.tools.ant.Project;
+import org.junit.Before;
+import org.junit.Test;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class ProjectWorkspaceReaderTest
+{
+
+ private ProjectWorkspaceReader reader;
+
+ private Project project;
+
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ this.reader = new ProjectWorkspaceReader();
+
+ this.project = new Project();
+ project.setProperty( "user.home", System.getProperty( "user.home" ) );
+ }
+
+ private Artifact artifact( String coords )
+ {
+ return new DefaultArtifact( coords );
+ }
+
+ private File getFile( String name )
+ {
+ return new File( "src/test/resources/ProjectWorkspaceReader", name );
+ }
+
+ @Test
+ public void testFindPom()
+ {
+ Pom pom = new Pom();
+ pom.setProject( project );
+ pom.setFile( getFile( "dummy-pom.xml" ) );
+
+ reader.addPom( pom );
+
+ assertEquals( pom.getFile(), reader.findArtifact( artifact( "test:dummy:pom:0.1-SNAPSHOT" ) ) );
+ assertNull( reader.findArtifact( artifact( "unavailable:test:pom:0.1-SNAPSHOT" ) ) );
+ }
+
+ @Test
+ public void testFindArtifact()
+ {
+ Pom pom = new Pom();
+ pom.setProject( project );
+ pom.setFile( getFile( "dummy-pom.xml" ) );
+
+ reader.addPom( pom );
+
+ org.apache.maven.resolver.internal.ant.types.Artifact artifact = new org.apache.maven.resolver.internal.ant.types.Artifact();
+ artifact.setProject( project );
+ artifact.addPom( pom );
+ artifact.setFile( getFile( "dummy-file.txt" ) );
+
+ reader.addArtifact( artifact );
+
+ assertEquals( artifact.getFile(), reader.findArtifact( artifact( "test:dummy:txt:0.1-SNAPSHOT" ) ) );
+ assertNull( reader.findArtifact( artifact( "unavailable:test:jar:0.1-SNAPSHOT" ) ) );
+ }
+
+ @Test
+ public void testFindVersions()
+ {
+ Pom pom1 = new Pom();
+ pom1.setProject( project );
+ pom1.setCoords( "test:dummy:1-SNAPSHOT" );
+
+ org.apache.maven.resolver.internal.ant.types.Artifact artifact1 = new org.apache.maven.resolver.internal.ant.types.Artifact();
+ artifact1.setProject( project );
+ artifact1.addPom( pom1 );
+ artifact1.setFile( getFile( "dummy-file.txt" ) );
+
+ reader.addArtifact( artifact1 );
+
+ Pom pom2 = new Pom();
+ pom2.setProject( project );
+ pom2.setCoords( "test:dummy:2-SNAPSHOT" );
+
+ org.apache.maven.resolver.internal.ant.types.Artifact artifact2 = new org.apache.maven.resolver.internal.ant.types.Artifact();
+ artifact2.setProject( project );
+ artifact2.addPom( pom2 );
+ artifact2.setFile( getFile( "dummy-file.txt" ) );
+
+ reader.addArtifact( artifact2 );
+
+ assertThat( reader.findVersions( artifact( "test:dummy:txt:[0,)" ) ),
+ containsInAnyOrder( "1-SNAPSHOT", "2-SNAPSHOT" ) );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
new file mode 100644
index 0000000..6b33710
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
@@ -0,0 +1,100 @@
+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.io.IOException;
+
+import org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+
+public class ReactorTest
+ extends AntBuildsTest
+{
+
+ private Artifact artifact( String coords )
+ {
+ return new DefaultArtifact( coords );
+ }
+
+ public void testPom()
+ throws IOException
+ {
+ executeTarget( "testPom" );
+ ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
+ File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
+ assertNotNull( found );
+ assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
+ }
+
+ public void testArtifact()
+ throws IOException
+ {
+ executeTarget( "testArtifact" );
+ ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
+ File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
+ assertNotNull( found );
+ assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
+
+ found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
+ assertNotNull( found );
+ assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
+ }
+
+ public void testArtifactInMemoryPom()
+ throws IOException
+ {
+ executeTarget( "testArtifactInMemoryPom" );
+ ProjectWorkspaceReader reader = ProjectWorkspaceReader.getInstance();
+ File found = reader.findArtifact( artifact( "test:test:pom:0.1-SNAPSHOT" ) );
+ assertNull( found );
+
+ found = reader.findArtifact( artifact( "test:test:xml:0.1-SNAPSHOT" ) );
+ assertNotNull( found );
+ assertEquals( new File( projectDir, "pom1.xml" ), found.getAbsoluteFile() );
+ }
+
+ public void testResolveArtifact()
+ throws IOException
+ {
+ executeTarget( "testResolveArtifact" );
+ String prop = project.getProperty( "resolve.test:test:jar" );
+ assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
+ }
+
+ public void testResolveArtifactInMemoryPom()
+ throws IOException
+ {
+ executeTarget( "testResolveArtifactInMemoryPom" );
+ String prop = project.getProperty( "resolve.test:test:jar" );
+ assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
+ assertLogContaining( "The POM for test:test:jar:0.1-SNAPSHOT is missing, no dependency information available" );
+ }
+
+ public void testResolveVersionRange()
+ throws IOException
+ {
+ executeTarget( "testResolveVersionRange" );
+ String prop = project.getProperty( "resolve.test:test:jar" );
+ assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
new file mode 100644
index 0000000..a736a74
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/ResolveTest.java
@@ -0,0 +1,150 @@
+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 static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.FileResource;
+
+public class ResolveTest
+ extends AntBuildsTest
+{
+
+ public void testResolveGlobalPom()
+ {
+ executeTarget( "testResolveGlobalPom" );
+
+ String prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-api:jar" );
+ assertThat( "aether-api was not resolved as a property", prop, notNullValue() );
+ assertThat( "aether-api was not resolved to default local repository", prop,
+ allOf( containsString( "aether-api" ), endsWith( ".jar" ) ) );
+ }
+
+ public void testResolveOverrideGlobalPom()
+ {
+ executeTarget( "testResolveOverrideGlobalPom" );
+
+ String prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-api:jar" );
+ assertThat( "aether-api was not resolved as a property", prop, notNullValue() );
+ assertThat( "aether-api was not resolved to default local repository", prop,
+ allOf( containsString( "aether-api" ), endsWith( ".jar" ) ) );
+ }
+
+ public void testResolveGlobalPomIntoOtherLocalRepo()
+ {
+ executeTarget( "testResolveGlobalPomIntoOtherLocalRepo" );
+
+ String prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-api:jar" );
+ assertThat( "aether-api was not resolved as a property", prop, notNullValue() );
+ assertThat( "aether-api was not resolved to default local repository", prop.replace( '\\', '/' ),
+ endsWith( "local-repo-custom/org/eclipse/aether/aether-api/0.9.0.M3/aether-api-0.9.0.M3.jar" ) );
+ }
+
+ public void testResolveCustomFileLayout()
+ throws IOException
+ {
+ File dir = new File( BUILD_DIR, "resolve-custom-layout" );
+ executeTarget( "testResolveCustomFileLayout" );
+
+ assertThat( "aether-api was not saved with custom file layout",
+ new File( dir, "org.eclipse.aether/aether-api/org/eclipse/aether/jar" ).exists() );
+ }
+
+ public void testResolveAttachments()
+ throws IOException
+ {
+ File dir = new File( BUILD_DIR, "resolve-attachments" );
+ executeTarget( "testResolveAttachments" );
+
+ File jdocDir = new File(dir, "javadoc");
+
+ assertThat( "aether-api-javadoc was not saved with custom file layout",
+ new File( jdocDir, "org.eclipse.aether-aether-api-javadoc.jar" ).exists() );
+
+ assertThat( "found non-javadoc files", Arrays.asList( jdocDir.list() ), everyItem( endsWith( "javadoc.jar" ) ) );
+
+ File sourcesDir = new File( dir, "sources" );
+ assertThat( "aether-api-sources was not saved with custom file layout",
+ new File( sourcesDir, "org.eclipse.aether-aether-api-sources.jar" ).exists() );
+ assertThat( "found non-sources files", Arrays.asList( sourcesDir.list() ),
+ everyItem( endsWith( "sources.jar" ) ) );
+ }
+
+ public void testResolvePath()
+ {
+ executeTarget( "testResolvePath" );
+ Map<?, ?> refs = getProject().getReferences();
+ Object obj = refs.get( "out" );
+ assertThat( "ref 'out' is no path", obj, instanceOf( Path.class ) );
+ Path path = (Path) obj;
+ String[] elements = path.list();
+ assertThat( "no aether-api on classpath", elements,
+ hasItemInArray( allOf( containsString( "aether-api" ), endsWith( ".jar" ) ) ) );
+ }
+
+ public void testResolveDepsFromFile()
+ {
+ executeTarget( "testResolveDepsFromFile" );
+
+ String prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-spi:jar" );
+ assertThat( "aether-spi was not resolved as a property", prop, notNullValue() );
+ assertThat( "aether-spi was not resolved to default local repository", prop,
+ allOf( containsString( "aether-spi" ), endsWith( ".jar" ) ) );
+ prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-api:jar" );
+ assertThat( "aether-api was resolved as a property", prop, nullValue() );
+ }
+
+ public void testResolveNestedDependencyCollections()
+ {
+ executeTarget( "testResolveNestedDependencyCollections" );
+
+ String prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-spi:jar" );
+ assertThat( "aether-spi was not resolved as a property", prop, notNullValue() );
+ prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-util:jar" );
+ assertThat( "aether-util was not resolved as a property", prop, notNullValue() );
+ prop = getProject().getProperty( "test.resolve.path.org.eclipse.aether:aether-api:jar" );
+ assertThat( "aether-api was resolved as a property", prop, nullValue() );
+ }
+
+ public void testResolveResourceCollectionOnly()
+ {
+ executeTarget( "testResolveResourceCollectionOnly" );
+
+ ResourceCollection resources = (ResourceCollection) getProject().getReference( "files" );
+ assertThat( resources, is( notNullValue() ) );
+ assertThat( resources.size(), is( 2 ) );
+ assertThat( resources.isFilesystemOnly(), is( true ) );
+ Iterator<?> it = resources.iterator();
+ FileResource file = (FileResource) it.next();
+ assertThat( file.getFile().getName(), is( "aether-spi-0.9.0.v20140226.jar" ) );
+ file = (FileResource) it.next();
+ assertThat( file.getFile().getName(), is( "aether-api-0.9.0.v20140226.jar" ) );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/SettingsTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/SettingsTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/SettingsTest.java
new file mode 100644
index 0000000..a22d573
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/SettingsTest.java
@@ -0,0 +1,65 @@
+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 static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.resolver.internal.ant.AntRepoSys;
+
+public class SettingsTest
+ extends AntBuildsTest
+{
+
+ public void testUserSettings()
+ {
+ executeTarget( "testUserSettings" );
+ assertThat( "user settings not set", AntRepoSys.getInstance( getProject() ).getUserSettings().getName(),
+ equalTo( "userSettings.xml" ) );
+ }
+
+ public void testGlobalSettings()
+ {
+ executeTarget( "testGlobalSettings" );
+ assertThat( "global settings not set", AntRepoSys.getInstance( getProject() ).getGlobalSettings().getName(),
+ equalTo( "globalSettings.xml" ) );
+ }
+
+ public void testBothSettings()
+ {
+ executeTarget( "testBothSettings" );
+ assertThat( "global settings not set", AntRepoSys.getInstance( getProject() ).getGlobalSettings().getName(),
+ equalTo( "globalSettings.xml" ) );
+ assertThat( "user settings not set", AntRepoSys.getInstance( getProject() ).getUserSettings().getName(),
+ equalTo( "userSettings.xml" ) );
+ }
+
+ public void testFallback()
+ throws IOException
+ {
+ executeTarget("setUp");
+ assertThat( "no fallback to local settings",
+ AntRepoSys.getInstance( getProject() ).getUserSettings().getAbsolutePath(), endsWith( ".m2"
+ + File.separator + "settings.xml" ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/tasks/LayoutTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/tasks/LayoutTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/tasks/LayoutTest.java
new file mode 100644
index 0000000..f79729b
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/tasks/LayoutTest.java
@@ -0,0 +1,55 @@
+package org.apache.maven.resolver.internal.ant.tasks;
+
+/*
+ * 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.resolver.internal.ant.tasks.Layout;
+import org.apache.tools.ant.BuildException;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.junit.Test;
+
+/**
+ */
+public class LayoutTest
+{
+
+ @Test( expected = BuildException.class )
+ public void testUnknownVariable()
+ {
+ new Layout( "{unknown}" );
+ }
+
+ @Test
+ public void testGetPath()
+ {
+ Layout layout;
+
+ layout =
+ new Layout( "{groupIdDirs}/{artifactId}/{baseVersion}/{artifactId}-{version}-{classifier}.{extension}" );
+ assertEquals( "org/apache/maven/maven-model/3.0-SNAPSHOT/maven-model-3.0-20100720.132618-1.jar",
+ layout.getPath( new DefaultArtifact( "org.apache.maven:maven-model:3.0-20100720.132618-1" ) ) );
+
+ layout = new Layout( "{groupId}/{artifactId}-{version}-{classifier}.{extension}" );
+ assertEquals( "org.apache.maven/maven-model-3.0-sources.jar",
+ layout.getPath( new DefaultArtifact( "org.apache.maven:maven-model:jar:sources:3.0" ) ) );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/DependencyTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/DependencyTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/DependencyTest.java
new file mode 100644
index 0000000..10ca42b
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/DependencyTest.java
@@ -0,0 +1,88 @@
+package org.apache.maven.resolver.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 static org.junit.Assert.*;
+
+import org.apache.maven.resolver.internal.ant.types.Dependency;
+import org.junit.Test;
+
+/**
+ */
+public class DependencyTest
+{
+
+ @Test
+ public void testSetCoordsGidAidVer()
+ {
+ Dependency dep = new Dependency();
+ dep.setCoords( "gid:aid:ver" );
+
+ assertEquals( "gid", dep.getGroupId() );
+ assertEquals( "aid", dep.getArtifactId() );
+ assertEquals( "ver", dep.getVersion() );
+ assertEquals( "jar", dep.getType() );
+ assertEquals( "", dep.getClassifier() );
+ assertEquals( "compile", dep.getScope() );
+ }
+
+ @Test
+ public void testSetCoordsGidAidVerScope()
+ {
+ Dependency dep = new Dependency();
+ dep.setCoords( "gid:aid:ver:scope" );
+
+ assertEquals( "gid", dep.getGroupId() );
+ assertEquals( "aid", dep.getArtifactId() );
+ assertEquals( "ver", dep.getVersion() );
+ assertEquals( "jar", dep.getType() );
+ assertEquals( "", dep.getClassifier() );
+ assertEquals( "scope", dep.getScope() );
+ }
+
+ @Test
+ public void testSetCoordsGidAidVerTypeScope()
+ {
+ Dependency dep = new Dependency();
+ dep.setCoords( "gid:aid:ver:type:scope" );
+
+ assertEquals( "gid", dep.getGroupId() );
+ assertEquals( "aid", dep.getArtifactId() );
+ assertEquals( "ver", dep.getVersion() );
+ assertEquals( "type", dep.getType() );
+ assertEquals( "", dep.getClassifier() );
+ assertEquals( "scope", dep.getScope() );
+ }
+
+ @Test
+ public void testSetCoordsGidAidVerTypeClsScope()
+ {
+ Dependency dep = new Dependency();
+ dep.setCoords( "gid:aid:ver:type:cls:scope" );
+
+ assertEquals( "gid", dep.getGroupId() );
+ assertEquals( "aid", dep.getArtifactId() );
+ assertEquals( "ver", dep.getVersion() );
+ assertEquals( "type", dep.getType() );
+ assertEquals( "cls", dep.getClassifier() );
+ assertEquals( "scope", dep.getScope() );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/ExclusionTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/ExclusionTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/ExclusionTest.java
new file mode 100644
index 0000000..64d510f
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/ExclusionTest.java
@@ -0,0 +1,88 @@
+package org.apache.maven.resolver.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 static org.junit.Assert.*;
+
+import org.apache.maven.resolver.internal.ant.types.Exclusion;
+import org.junit.Test;
+
+/**
+ */
+public class ExclusionTest
+{
+
+ @Test
+ public void testSetCoordsGid()
+ {
+ Exclusion ex = new Exclusion();
+ ex.setCoords( "gid" );
+
+ assertEquals( "gid", ex.getGroupId() );
+ assertEquals( "*", ex.getArtifactId() );
+ assertEquals( "*", ex.getExtension() );
+ assertEquals( "*", ex.getClassifier() );
+ }
+
+ @Test
+ public void testSetCoordsGidAid()
+ {
+ Exclusion ex = new Exclusion();
+ ex.setCoords( "gid:aid" );
+
+ assertEquals( "gid", ex.getGroupId() );
+ assertEquals( "aid", ex.getArtifactId() );
+ assertEquals( "*", ex.getExtension() );
+ assertEquals( "*", ex.getClassifier() );
+ }
+
+ @Test
+ public void testSetCoordsGidAidExt()
+ {
+ Exclusion ex = new Exclusion();
+ ex.setCoords( "gid:aid:ext" );
+
+ assertEquals( "gid", ex.getGroupId() );
+ assertEquals( "aid", ex.getArtifactId() );
+ assertEquals( "ext", ex.getExtension() );
+ assertEquals( "*", ex.getClassifier() );
+ }
+
+ @Test
+ public void testSetCoordsGidAidExtCls()
+ {
+ Exclusion ex = new Exclusion();
+ ex.setCoords( "gid:aid:ext:cls" );
+
+ assertEquals( "gid", ex.getGroupId() );
+ assertEquals( "aid", ex.getArtifactId() );
+ assertEquals( "ext", ex.getExtension() );
+ assertEquals( "cls", ex.getClassifier() );
+
+ ex = new Exclusion();
+ ex.setCoords( "gid:aid:ext:" );
+
+ assertEquals( "gid", ex.getGroupId() );
+ assertEquals( "aid", ex.getArtifactId() );
+ assertEquals( "ext", ex.getExtension() );
+ assertEquals( "", ex.getClassifier() );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/PomTest.java
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/PomTest.java b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/PomTest.java
new file mode 100644
index 0000000..35131b1
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/java/org/apache/maven/resolver/internal/ant/types/PomTest.java
@@ -0,0 +1,43 @@
+package org.apache.maven.resolver.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 static org.junit.Assert.*;
+
+import org.apache.maven.resolver.internal.ant.types.Pom;
+import org.junit.Test;
+
+/**
+ */
+public class PomTest
+{
+
+ @Test
+ public void testSetCoordsGid()
+ {
+ Pom pom = new Pom();
+ pom.setCoords( "gid:aid:ver" );
+
+ assertEquals( "gid", pom.getGroupId() );
+ assertEquals( "aid", pom.getArtifactId() );
+ assertEquals( "ver", pom.getVersion() );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-file.txt
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-file.txt b/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-file.txt
new file mode 100644
index 0000000..b8a5cfa
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-file.txt
@@ -0,0 +1 @@
+A test artifact.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-resolver/blob/a088cdfc/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-pom.xml
----------------------------------------------------------------------
diff --git a/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-pom.xml b/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-pom.xml
new file mode 100644
index 0000000..0041f8c
--- /dev/null
+++ b/maven-resolver-ant-tasks/src/test/resources/ProjectWorkspaceReader/dummy-pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>test</groupId>
+ <artifactId>dummy</artifactId>
+ <version>0.1-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>