mirror of https://github.com/apache/ant-ivy
Merge pull request #119 from eric-milles/IVY-1665
IVY-1665: `checkdepsupdate`: verify version is greater before reporting on available update
This commit is contained in:
commit
a569ad67b8
|
|
@ -28,6 +28,10 @@ import org.apache.ivy.core.module.id.ModuleRevisionId;
|
|||
import org.apache.ivy.core.report.ResolveReport;
|
||||
import org.apache.ivy.core.resolve.IvyNode;
|
||||
import org.apache.ivy.core.resolve.ResolveOptions;
|
||||
import org.apache.ivy.plugins.latest.ArtifactInfo;
|
||||
import org.apache.ivy.plugins.latest.LatestStrategy;
|
||||
import org.apache.ivy.plugins.resolver.DependencyResolver;
|
||||
import org.apache.ivy.plugins.resolver.util.HasLatestStrategy;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
|
||||
|
|
@ -127,9 +131,11 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask {
|
|||
boolean dependencyUpdateDetected = false;
|
||||
for (IvyNode latest : latestReport.getDependencies()) {
|
||||
for (IvyNode originalDependency : originalReport.getDependencies()) {
|
||||
if (originalDependency.getModuleId().equals(latest.getModuleId())) {
|
||||
if (!originalDependency.getResolvedId().getRevision()
|
||||
.equals(latest.getResolvedId().getRevision())) {
|
||||
if (latest.getModuleId().equals(originalDependency.getModuleId())) {
|
||||
ArtifactInfo in1 = toArtifactInfo(latest);
|
||||
ArtifactInfo in2 = toArtifactInfo(originalDependency);
|
||||
ArtifactInfo out = getLatestStrategy(originalDependency).findLatest(new ArtifactInfo[]{in1, in2}, null);
|
||||
if (out == in1) {
|
||||
// is this dependency a transitive or a direct dependency?
|
||||
// (unfortunately .isTransitive() methods do not have the same meaning)
|
||||
boolean isTransitiveDependency = latest.getDependencyDescriptor(latest
|
||||
|
|
@ -144,7 +150,6 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask {
|
|||
dependencyUpdateDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -195,4 +200,27 @@ public class IvyDependencyUpdateChecker extends IvyPostResolveTask {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
private LatestStrategy getLatestStrategy(IvyNode node) {
|
||||
DependencyResolver resolver = getSettings().getResolver(node.getResolvedId());
|
||||
if (resolver instanceof HasLatestStrategy) {
|
||||
return ((HasLatestStrategy) resolver).getLatestStrategy();
|
||||
}
|
||||
return getSettings().getDefaultLatestStrategy();
|
||||
}
|
||||
|
||||
private static ArtifactInfo toArtifactInfo(IvyNode node) {
|
||||
return new ArtifactInfo() {
|
||||
@Override
|
||||
public String getRevision() {
|
||||
return node.getResolvedId().getRevision();
|
||||
}
|
||||
@Override
|
||||
public long getLastModified() {
|
||||
return node.getLastModified();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,6 +220,26 @@ public class IvyDependencyUpdateCheckerTest extends AntTaskTestCase {
|
|||
assertLogContaining("org1#mod1.2\t2.0 -> 2.2");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test case for IVY-1665.
|
||||
*
|
||||
* @see <a href="https://issues.apache.org/jira/browse/IVY-1665">IVY-1665</a>
|
||||
*/
|
||||
@Test
|
||||
public void testLatestRelease() {
|
||||
dependencyUpdateChecker.getProject().setProperty("ivy.settings.file", "test/repositories/IVY-1665/ivysettings.xml");
|
||||
dependencyUpdateChecker.setRevisionToCheck("latest.release"); // exclude milestone (2.0-M1)
|
||||
dependencyUpdateChecker.setOrganisation("bar");
|
||||
dependencyUpdateChecker.setModule("foo");
|
||||
dependencyUpdateChecker.setRevision("2.0-M1");
|
||||
dependencyUpdateChecker.setInline(true);
|
||||
dependencyUpdateChecker.execute();
|
||||
|
||||
assertLogNotContaining("bar#foo\t2.0-M1 -> 1.0");
|
||||
// expect listing for 2.0 when it comes available
|
||||
assertLogContaining("All dependencies are up to date");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleExtends() {
|
||||
dependencyUpdateChecker.setFile(new File("test/java/org/apache/ivy/ant/ivy-extends-multiconf.xml"));
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
|
|
@ -0,0 +1 @@
|
|||
.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<!--
|
||||
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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="bar" module="foo" revision="1.0" status="release"/>
|
||||
</ivy-module>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<!--
|
||||
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
|
||||
|
||||
https://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.
|
||||
-->
|
||||
|
||||
<ivy-module version="2.0">
|
||||
<info organisation="bar" module="foo" revision="2.0-M1" status="integration"/>
|
||||
</ivy-module>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
https://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.
|
||||
-->
|
||||
|
||||
<ivysettings>
|
||||
<settings defaultResolver="local"/>
|
||||
<resolvers>
|
||||
<filesystem name="local">
|
||||
<ivy pattern="${ivy.settings.dir}/[organisation]/[module]/ivy-[revision].xml"/>
|
||||
<artifact pattern="${ivy.settings.dir}/[organisation]/[module]/[artifact]-[revision].[ext]"/>
|
||||
</filesystem>
|
||||
</resolvers>
|
||||
</ivysettings>
|
||||
Loading…
Reference in New Issue