Hi Martin,

Detecting cycles at the class level seems like a less common use case, and
thus harder to achieve out of the box.

I played a bit with jdeps -- from the docs, it seems like it should be able
to emit output along the lines you are looking for -- but I could not get
it to behave within 10 minutes. Maybe someone else here has more experience
with it.

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden


On Wed, Jan 11, 2017 at 6:10 AM, Martin Gainty <mgai...@hotmail.com> wrote:

> all:
>  I need to catch a class cycle for example:
>
> package fubar;
>
> class classA
>
> {
>
>  classB classb; //i need to detect this cycle
>
> }
>
>
> package fubar;
>
> class classB extends classA
> {
>  classA classa; //ok since child class can reach to base class
>
> }
>
>
> does maven-enforcer-plugin have a rule which will detect class cycle
> illustrated above?
>
> Thanks!
>
> Martin
> ______________________________________________
>
>
>
> ________________________________
> From: ctrueden.w...@gmail.com <ctrueden.w...@gmail.com> on behalf of
> Curtis Rueden <ctrue...@wisc.edu>
> Sent: Tuesday, January 10, 2017 12:13 PM
> To: Maven Users List
> Subject: Re: maven-enforcer-plugin rules question
>
> Hi Martin,
>
> I do not see how your example constitutes a "package cycle"? Both ClassA
> and ClassB belong to the same package.
>
> Put ClassA or ClassB into a different package, and see if the rule
> complains.
>
> Regards,
> Curtis
>
> --
> Curtis Rueden
> LOCI software architect - http://loci.wisc.edu/software
> ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
>
>
> On Tue, Jan 10, 2017 at 11:05 AM, Martin Gainty <mgai...@hotmail.com>
> wrote:
>
> > i couldnt get it this cycle failure:
> >
> > Test set: de.andrena.tools.nopackagecycles.PackageCycleCollectorPerfor
> man
> > ceTest
> > ------------------------------------------------------------
> > -------------------
> > Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 sec
> > - in de.andrena.tools.nopackagecycles.PackageCycleCollectorPerfor
> manceTest
> >
> >
> >
> > package de.andrena.tools.nopackagecycles;
> > import static org.hamcrest.MatcherAssert.assertThat;
> > import static org.hamcrest.Matchers.empty;
> > import static org.hamcrest.Matchers.is;
> > import java.util.ArrayList;
> > import java.util.Collections;
> > import java.util.HashSet;
> > import java.util.List;
> > import java.util.Set;
> > import jdepend.framework.JavaPackage;
> > import org.junit.Before;
> > import org.junit.Test;
> > import de.andrena.tools.nopackagecycles.ClassB;
> >
> > public class ClassB extends ClassA
> > {
> >  public ClassA classA=null; //OK
> > }
> >
> >
> >
> > public class PackageCycleCollectorPerformanceTest {
> >
> >
> > //add one obvious cycle
> >
> >
> >     public void findRealPackageCycle() throws Exception {
> > JavaPackage javaPackage =new JavaPackage("de.andrena.tools.
> > nopackagecycles");
> > JavaClass javaClassA=new JavaClass("ClassA");
> > javaPackage.addClass(javaClassA);
> > JavaClass javaClassB=new JavaClass("ClassB");
> > javaPackage.addClass(javaClassB);
> > allPackages.add(javaPackage);
> >    List<Set<JavaPackage>> cycles = new PackageCycleCollector().
> > collectCycles(allPackages);
> > assertThat(cycles, is(empty()));
> > }
> > ...
> > }
> >
> >
> > package de.andrena.tools.nopackagecycles;
> > import static org.hamcrest.MatcherAssert.assertThat;
> > import static org.hamcrest.Matchers.empty;
> > import static org.hamcrest.Matchers.is;
> > import java.util.ArrayList;
> > import java.util.Collections;
> > import java.util.HashSet;
> > import java.util.List;
> > import java.util.Set;
> > import jdepend.framework.JavaPackage;
> > import org.junit.Before;
> > import org.junit.Test;
> > import de.andrena.tools.nopackagecycles.ClassB;
> > public class ClassA
> > {
> >  public de.andrena.tools.nopackagecycles.ClassB classB=null; //detect
> > this cycle!
> > }
> >
> >
> > what am i doing wrong?
> >
> >
> > Thanks Curtis
> >
> > Martin
> > ______________________________________________
> >
> >
> > ________________________________
> > From: ctrueden.w...@gmail.com <ctrueden.w...@gmail.com> on behalf of
> > Curtis Rueden <ctrue...@wisc.edu>
> > Sent: Tuesday, January 10, 2017 11:02 AM
> > To: Maven Users List
> > Subject: Re: maven-enforcer-plugin rules question
> >
> > Hi Martin,
> >
> > A quick Google search revealed this:
> > https://github.com/andrena/no-package-cycles-enforcer-rule
> > [https://avatars2.githubusercontent.com/u/1824230?v=3&s=400]<https://
> > github.com/andrena/no-package-cycles-enforcer-rule>
> >
> > GitHub - andrena/no-package-cycles-enforcer-rule ...<https://github.com/
> > andrena/no-package-cycles-enforcer-rule>
> > github.com
> > no-package-cycles-enforcer-rule - Shamelessly copied and improved from
> > http://stackoverflow.com/questions/3416547/maven-
> > jdepend-fail-build-with-cycles
> >
> >
> >
> >
> > I haven't tried it personally. Though now that I know about it, I'm
> sorely
> > tempted-it would certainly improve the API design.
> >
> > Regards,
> > Curtis
> >
> > --
> > Curtis Rueden
> > LOCI software architect - http://loci.wisc.edu/software
> > ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden
> > [https://gravatar.com/avatar/63df759e2779af56fd050a968ff98d09]<
> > http://imagej.net/User:Rueden>
> >
> > User:Rueden - ImageJ<http://imagej.net/User:Rueden>
> > imagej.net
> > What is Curtis working on? Primary projects. Here is a summary of my
> > current projects, in priority order. I try to keep this list up to date.
> > The ImageJ2 paper.
> >
> >
> >
> >
> >
> > On Tue, Jan 10, 2017 at 9:34 AM, Martin Gainty <mgai...@hotmail.com>
> > wrote:
> >
> > > I need to detect package cycles such as what is seen here:
> > >
> > > class ClassA
> > >
> > > {
> > >
> > >  ClassB classB; //detect this package cycle!
> > >
> > > }
> > > class ClassB extends ClassA
> > >
> > > {
> > >
> > > }
> > >
> > >
> > > which maven-enforcer-plugin rule will allow me to detect package cycle?
> > >
> > >
> > > http://maven.apache.org/enforcer/enforcer-rules/index.html
> > Apache Maven Enforcer Rules - Standard Rules<http://maven.apache.org/
> > enforcer/enforcer-rules/index.html>
> > maven.apache.org
> > Standard Rules. The following standard rules ship along with the enforcer
> > plugin: alwaysFail - Always fail... used to test plugin configuration.
> > alwaysPass - Always ...
> >
> >
> >
> > >
> > > Apache Maven Enforcer Rules - Standard Rules<http://maven.apache.org/
> > > enforcer/enforcer-rules/index.html>
> > > maven.apache.org
> > > Standard Rules. The following standard rules ship along with the
> enforcer
> > > plugin: alwaysFail - Always fail... used to test plugin configuration.
> > > alwaysPass - Always ...
> > >
> > >
> > >
> > >
> > > Thanks!
> > >
> > > Martin
> > > ______________________________________________
> > >
> > >
> >
>

Reply via email to