You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2021/09/12 10:41:11 UTC
[maven-resolver-ant-tasks] 01/01: [MRESOLVER-181] Upgrade Ant to
1.9.15
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MRESOLVER-181
in repository https://gitbox.apache.org/repos/asf/maven-resolver-ant-tasks.git
commit dc469908e2c04e537ae7879efe042f31bfd286f6
Author: Nils Breunese <ni...@breun.nl>
AuthorDate: Sun May 16 20:36:44 2021 +0200
[MRESOLVER-181] Upgrade Ant to 1.9.15
o Updated to Ant 1.9.15
o Replaced use of BuildFileTest with BuildFileRule
o Integration tests are not passing yet
This closes #6
---
pom.xml | 2 +-
.../maven/resolver/internal/ant/AntBuildsTest.java | 64 ++++++++++++++--------
.../internal/ant/ProjectWorkspaceReaderTest.java | 1 -
.../maven/resolver/internal/ant/ReactorTest.java | 13 +++--
4 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/pom.xml b/pom.xml
index 46f6bcc..792995e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
<properties>
<mavenVersion>3.6.3</mavenVersion>
<resolverVersion>1.7.2</resolverVersion>
- <antVersion>1.8.4</antVersion>
+ <antVersion>1.9.15</antVersion>
<javaVersion>8</javaVersion>
<maven.site.path>resolver-archives/resolver-ant-tasks-LATEST</maven.site.path>
<checkstyle.violation.ignore>LineLength,MagicNumber</checkstyle.violation.ignore>
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
index 0c3c309..87102af 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/AntBuildsTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* 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
@@ -22,15 +22,18 @@ package org.apache.maven.resolver.internal.ant;
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.BuildFileRule;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.eclipse.aether.internal.test.util.TestFileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+
+import static org.junit.Assert.assertTrue;
public abstract class AntBuildsTest
- extends BuildFileTest
{
private static final File BASE_DIR;
@@ -43,6 +46,9 @@ public abstract class AntBuildsTest
BUILD_DIR = new File( BASE_DIR, "target/ant" );
}
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
+
protected File projectDir;
protected File localRepoDir;
@@ -65,12 +71,10 @@ public abstract class AntBuildsTest
// hook for subclasses to set further system properties for the project to pick up
}
- @Override
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
-
TestFileUtils.deleteFile( BUILD_DIR );
projectDir = new File( new File( BASE_DIR, "src/test/resources/ant" ), getProjectDirName() );
@@ -90,26 +94,38 @@ public abstract class AntBuildsTest
configureProject( new File( projectDir, "ant.xml" ).getAbsolutePath(), Project.MSG_VERBOSE );
}
- @Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
- try
- {
- ProjectWorkspaceReader.dropInstance();
- TestFileUtils.deleteFile( BUILD_DIR );
- }
- finally
- {
- super.tearDown();
- }
+ ProjectWorkspaceReader.dropInstance();
+ TestFileUtils.deleteFile( BUILD_DIR );
+ }
+
+ protected void assertLogContaining( String substring )
+ {
+ String realLog = getLog();
+ assertTrue( "expecting log to contain \"" + substring + "\" log was \"" + realLog + "\"", realLog.contains( substring ) );
+ }
+
+ protected void executeTarget( String targetName ) {
+ buildRule.executeTarget( targetName );
+ }
+
+ protected String getLog()
+ {
+ return buildRule.getLog();
+ }
+
+ protected Project getProject()
+ {
+ return buildRule.getProject();
}
- @Override
- public void configureProject( String filename, int logLevel )
+ private void configureProject( String filename, int logLevel )
throws BuildException
{
- super.configureProject( filename, logLevel );
+ buildRule.configureProject( filename, logLevel );
DefaultLogger logger = new DefaultLogger()
{
@Override
@@ -122,7 +138,7 @@ public abstract class AntBuildsTest
logger.setMessageOutputLevel( logLevel );
logger.setOutputPrintStream( System.out );
logger.setErrorPrintStream( System.err );
- getProject().addBuildListener( logger );
+ buildRule.getProject().addBuildListener( logger );
}
}
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
index 0b7dfa3..daadc1e 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/ProjectWorkspaceReaderTest.java
@@ -24,7 +24,6 @@ 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;
diff --git a/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java b/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
index 6b33710..3492ecc 100644
--- a/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
+++ b/src/test/java/org/apache/maven/resolver/internal/ant/ReactorTest.java
@@ -8,9 +8,9 @@ package org.apache.maven.resolver.internal.ant;
* 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
@@ -22,10 +22,11 @@ package org.apache.maven.resolver.internal.ant;
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;
+import static org.junit.Assert.*;
+
public class ReactorTest
extends AntBuildsTest
{
@@ -76,7 +77,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveArtifact" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().getProperty( "resolve.test:test:jar" );
assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
}
@@ -84,7 +85,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveArtifactInMemoryPom" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().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" );
}
@@ -93,7 +94,7 @@ public class ReactorTest
throws IOException
{
executeTarget( "testResolveVersionRange" );
- String prop = project.getProperty( "resolve.test:test:jar" );
+ String prop = getProject().getProperty( "resolve.test:test:jar" );
assertEquals( new File( projectDir, "pom1.xml" ).getAbsolutePath(), prop );
}