Problems Detecting Cyclical Dependencies

4 views
Skip to first unread message

fallon....@googlemail.com

unread,
May 29, 2008, 9:54:39 AM5/29/08
to architecture-rules-users
Hello,

Seems like a great tool, however I too cannot get the tool to fail
with cyclical dependencies. Are you sure it works? I'm not.

I have three basic Maven projects, projectA , projectB and projectC.

In projectA, I have a class A

package com.richard.a;
import com.richard.b.B;

public class A {
private B b;

}

In projectB, I have a class B

package com.richard.b;
import com.richard.c.C;

public class B {
private C c;

}

And in projectC I have a class C

package com.richard.c;
import com.richard.a.A;

public class C {
private A a;

}

So the above projects have cyclical dcependency.

My test class is

package com.richard.a;
import
com.seventytwomiles.architecturerules.AbstractArchitectureRulesConfigurationTest;

public class SimpleArchitectureTest extends
AbstractArchitectureRulesConfigurationTest {

public String getConfigurationFileName() {
return "architecture-rules.xml";
}
public void testArchitecture() {
assertTrue(doTests());
}
}

My architecture-rules.xml is

<architecture>
<configuration>
<sources>
<source not-found="exception">..\projectA\target
\classes</source>
<source not-found="exception">..\projectB\target
\classes</source>
<source not-found="exception">..\projectC\target\classes</
source>
</sources>
<cyclicalDependency test="true"></cyclicalDependency>
</configuration>
</architecture>

But my tests akways pass, and the output is always

2008-05-29 14:39:01,388 INFO
com.seventytwomiles.architecturerules.services.AbstractArchitecturalRules
(AbstractArchitecturalRules.java:97) - instantiating new
AbstractArchitecturalRules
2008-05-29 14:39:01,388 INFO
com.seventytwomiles.architecturerules.services.CyclicRedundancyServiceImpl
(CyclicRedundancyServiceImpl.java:71) - instantiating new
CyclicRedundancyService
2008-05-29 14:39:01,388 INFO
com.seventytwomiles.architecturerules.services.CyclicRedundancyServiceImpl
(CyclicRedundancyServiceImpl.java:83) - cyclic redundancy check
requested
2008-05-29 14:39:01,388 INFO
com.seventytwomiles.architecturerules.services.CyclicRedundancyServiceImpl
(CyclicRedundancyServiceImpl.java:131) - found no cyclic redundancies
2008-05-29 14:39:01,388 INFO
com.seventytwomiles.architecturerules.services.CyclicRedundancyServiceImpl
(CyclicRedundancyServiceImpl.java:141) - cyclic redundancy test
completed


Any ideas??



Mykola Nikishov

unread,
May 29, 2008, 11:25:14 AM5/29/08
to architecture...@googlegroups.com
fallon....@googlemail.com writes:

> Hello,

Hi,

> Seems like a great tool, however I too cannot get the tool to fail
> with cyclical dependencies. Are you sure it works? I'm not.

Yes, I'm sure.

> I have three basic Maven projects, projectA , projectB and projectC.

You don't use maven-architecture-rules-plugin, right? And just old
plain technique which described at
http://architecturerules.googlecode.com/svn/docs/sample-configuration.html?

> In projectA, I have a class A

> In projectB, I have a class B

> And in projectC I have a class C

You sould have a 4th

> So the above projects have cyclical dcependency.

Definetly they have but only from your point of view.
From a-r's point of view all your projects are independent. So:
- projectA contains a single class A w/o any cyclical dependencies
- projectB contains a single class B w/o any cyclical dependencies
- projectC contains a single class C w/o any cyclical dependencies

> Any ideas??

Yes. Move your classes A, B and C into a single project
(i.e. projectA) and you'll see cyclical dependencies from the a-r's
POV ;-)

BTW, maven-architecture-rules-plugin is not ready for a such use
case. It wouldn't detect problems in a multi-module build.

--
MAN-UANIC

Mike Nereson

unread,
May 29, 2008, 11:30:58 AM5/29/08
to architecture...@googlegroups.com
Hi Fallon, Mykola

Fallon, thanks for providing code samples and the output in your email.

Unfortunately Architecture Rules does not detect indirect cyclic
dependencies yet, only direct dependencies.

> In projectA, I have a class A
> In projectB, I have a class B
> And in projectC I have a class C

A -> B -> C -> A is indirect
A -> B -> A is direct

http://72miles.com/architecturerules/cyclic-dependencies

I hope we can detect indirect dependencies in the future. Perhaps
there is someone out there who is interested in adding this
funcionality.

Fallon, thanks for taking the time to describe this issue to us. I
hope this helps explain the current state of the project in terms of
detecting dependencies.

Good luck.

~ Mike
~ 72miles.com

Reply all
Reply to author
Forward
0 new messages