You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Martin Gainty <mg...@hotmail.com> on 2017/01/10 15:34:20 UTC

maven-enforcer-plugin rules question

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 ...




Thanks!

Martin
______________________________________________


Re: maven-enforcer-plugin rules question

Posted by Curtis Rueden <ct...@wisc.edu>.
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 <mg...@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.wisc@gmail.com <ct...@gmail.com> on behalf of
> Curtis Rueden <ct...@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 <mg...@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.wisc@gmail.com <ct...@gmail.com> on behalf of
> > Curtis Rueden <ct...@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 <mg...@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
> > > ______________________________________________
> > >
> > >
> >
>

Re: maven-enforcer-plugin rules question

Posted by Martin Gainty <mg...@hotmail.com>.
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.wisc@gmail.com <ct...@gmail.com> on behalf of Curtis Rueden <ct...@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 <mg...@hotmail.com> wrote:

> i couldnt get it this cycle failure:
>
> Test set: de.andrena.tools.nopackagecycles.PackageCycleCollectorPerforman
> ceTest
> ------------------------------------------------------------
> -------------------
> Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 sec
> - in de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest
>
>
>
> 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.wisc@gmail.com <ct...@gmail.com> on behalf of
> Curtis Rueden <ct...@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 <mg...@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
> > ______________________________________________
> >
> >
>

Re: maven-enforcer-plugin rules question

Posted by Curtis Rueden <ct...@wisc.edu>.
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 <mg...@hotmail.com> wrote:

> i couldnt get it this cycle failure:
>
> Test set: de.andrena.tools.nopackagecycles.PackageCycleCollectorPerforman
> ceTest
> ------------------------------------------------------------
> -------------------
> Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 sec
> - in de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest
>
>
>
> 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.wisc@gmail.com <ct...@gmail.com> on behalf of
> Curtis Rueden <ct...@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 <mg...@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
> > ______________________________________________
> >
> >
>

Re: maven-enforcer-plugin rules question

Posted by Martin Gainty <mg...@hotmail.com>.
i found plugin that appears to address class-cycle issues found in class files


http://classycle.sourceforge.net/

Classycle<http://classycle.sourceforge.net/>
classycle.sourceforge.net
Home; Examples; Download; User Guide; API documentation; SourceForge project page. powered by : Classycle: Analysing Tools for Java Class and Package Dependencies


Using this exmaple:


public class ClassA
{
 public de.andrena.tools.nopackagecycles.ClassB classB=null; //detect this class cycle
}

public class ClassB extends ClassA
{
 public ClassA classA=null; //this is OK as it is Base Class
}



produces this xml output:


    <class name="de.andrena.tools.nopackagecycles.ClassA" sources="/fubar/Classycle1.4.2/classycle.jar" type="class" innerClass="false" size="389" usedBy="1" usesInternal="1" usesExternal="1" layer="0" cycle="de.andrena.tools.nopackagecycles.ClassA et al.">
      <classRef name="de.andrena.tools.nopackagecycles.ClassB" type="usedBy"/>
      <classRef name="java.lang.Object" type="usesExternal"/>                                         <!-- cycle here -->
      <classRef name="de.andrena.tools.nopackagecycles.ClassB" type="usesInternal"/>
    </class>

    <class name="de.andrena.tools.nopackagecycles.ClassB" sources="/fubar/Classycle1.4.2/classycle.jar" type="class" innerClass="false" size="412" usedBy="1" usesInternal="1" usesExternal="0" layer="0" cycle="de.andrena.tools.nopackagecycles.ClassA et al.">
      <classRef name="de.andrena.tools.nopackagecycles.ClassA" type="usedBy"/>
      <classRef name="de.andrena.tools.nopackagecycles.ClassA" type="usesInternal"/>
    </class>


I'll need to factor in some xslt magic to find cycle but I think we have a delta detected by this plugin


thanks all,

Martin
______________________________________________



________________________________
From: Martin Gainty <mg...@hotmail.com>
Sent: Tuesday, January 10, 2017 12:05 PM
To: Maven Users List
Subject: Re: maven-enforcer-plugin rules question


i couldnt get it this cycle failure:

Test set: de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 sec - in de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest



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.wisc@gmail.com <ct...@gmail.com> on behalf of Curtis Rueden <ct...@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 <mg...@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
> ______________________________________________
>
>

Re: maven-enforcer-plugin rules question

Posted by Martin Gainty <mg...@hotmail.com>.
i couldnt get it this cycle failure:

Test set: de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 sec - in de.andrena.tools.nopackagecycles.PackageCycleCollectorPerformanceTest



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.wisc@gmail.com <ct...@gmail.com> on behalf of Curtis Rueden <ct...@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 <mg...@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
> ______________________________________________
>
>

Re: maven-enforcer-plugin rules question

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi Martin,

A quick Google search revealed this:
https://github.com/andrena/no-package-cycles-enforcer-rule

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


On Tue, Jan 10, 2017 at 9:34 AM, Martin Gainty <mg...@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 ...
>
>
>
>
> Thanks!
>
> Martin
> ______________________________________________
>
>