Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions src/java/org/apache/ivy/ant/IvyDependencyUpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
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;

Expand Down Expand Up @@ -127,9 +131,11 @@ private void displayDependencyUpdates(ResolveReport originalReport, ResolveRepor
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
Expand All @@ -144,7 +150,6 @@ private void displayDependencyUpdates(ResolveReport originalReport, ResolveRepor
dependencyUpdateDetected = true;
}
}

}
}
}
Expand Down Expand Up @@ -195,4 +200,27 @@ private void displayNewDependencyOnLatest(ResolveReport originalReport, ResolveR
}
}
}

//--------------------------------------------------------------------------

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();
}
};
}
}
20 changes: 20 additions & 0 deletions test/java/org/apache/ivy/ant/IvyDependencyUpdateCheckerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ public void testResolveWithRelativeFile() {
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"));
Expand Down
1 change: 1 addition & 0 deletions test/repositories/IVY-1665/bar/foo/foo-1.0.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
1 change: 1 addition & 0 deletions test/repositories/IVY-1665/bar/foo/foo-2.0-M1.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.
22 changes: 22 additions & 0 deletions test/repositories/IVY-1665/bar/foo/ivy-1.0.xml
Original file line number Diff line number Diff line change
@@ -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>
22 changes: 22 additions & 0 deletions test/repositories/IVY-1665/bar/foo/ivy-2.0-M1.xml
Original file line number Diff line number Diff line change
@@ -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>
28 changes: 28 additions & 0 deletions test/repositories/IVY-1665/ivysettings.xml
Original file line number Diff line number Diff line change
@@ -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>