maven 2 current directory ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

maven 2 current directory ?

nicolas de loof
When I build my maven 2 project, the current directory is the project base directory, so that I can refer to test resources as
new File( "target/test-classes/xxx" );

When running on hudson, current directory is my HUDSON_HOME (or maybe my user home, they are same).

Is there a workaround to avoid this ?

Nico.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

stephenconnolly
public class MyTest // extends TestCase // if using JUnit 3.x
{
  @Test
  public void testSomething() {
    Properties config = new Properties();
    config.load(getClass().getResourceAsStream("/xxx"));
  }
}

That way you don't assume anything about the current directory, only
that test resources will be loaded by the same classloader as the test
classes.

If you still would rather get at the files directly...

getClass().getResource("/"+getClass().getName().replace('.','/')+".class")

returns the url of the test class, unless you are running your tests
in a very strange way, this url should either be
"jar:file:path/to/test-classes.jar!test.package.MyClass.class"
or
"file:path/to/test-classes/test/package/MyClass.class"

It is trivial to extract the test-classes path from either of these...
but given that you can package up test classes into a jar file your
best technique is to use getResource or getResourceAsStream to access
the resources directly.

-Stephen

On Dec 12, 2007 11:42 AM, nicolas de loof <[hidden email]> wrote:

> When I build my maven 2 project, the current directory is the project base
> directory, so that I can refer to test resources as
> new File( "target/test-classes/xxx" );
>
> When running on hudson, current directory is my HUDSON_HOME (or maybe my
> user home, they are same).
>
> Is there a workaround to avoid this ?
>
> Nico.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

nicolas de loof
I'm using the " getResource("").getFile() " -> target/test-classes workaround,
but TOO MANY of my test classes use Files and assume the basedir to be the maven project root.

This is a coding mistake, but I was searching for a global workaround on hudson side.

2007/12/12, Stephen Connolly <[hidden email]>:
public class MyTest // extends TestCase // if using JUnit 3.x
{
  @Test
  public void testSomething() {
    Properties config = new Properties();
    config.load(getClass().getResourceAsStream("/xxx"));
  }
}

That way you don't assume anything about the current directory, only
that test resources will be loaded by the same classloader as the test
classes.

If you still would rather get at the files directly...

getClass().getResource("/"+getClass().getName().replace('.','/')+".class")

returns the url of the test class, unless you are running your tests
in a very strange way, this url should either be
"jar:file:path/to/test-classes.jar!test.package.MyClass.class"
or
"file:path/to/test-classes/test/package/MyClass.class"

It is trivial to extract the test-classes path from either of these...
but given that you can package up test classes into a jar file your
best technique is to use getResource or getResourceAsStream to access
the resources directly.

-Stephen

On Dec 12, 2007 11:42 AM, nicolas de loof < [hidden email]> wrote:

> When I build my maven 2 project, the current directory is the project base
> directory, so that I can refer to test resources as
> new File( "target/test-classes/xxx" );
>
> When running on hudson, current directory is my HUDSON_HOME (or maybe my
> user home, they are same).
>
> Is there a workaround to avoid this ?
>
> Nico.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

stephenconnolly
Yeah, we had about 1700 unit tests that made exactly the same
mistake... only they assumed a custom directory layout, they modified
the original source files (so you had to revert to SCM after running
the unit tests), oh and the ant build script was buggy beyond belief,
recursively building one project 34 times just to make a release (to
be sure to be sure)... When I moved to Maven2 as a build process it
took me about a day to fix it though and now at least it's portable
even if we were to move away from Maven. (our build is now down to 54
minutes from 6-8 hours too)

In fairness to ant, it was more that the original build script was a
load of manure.  The main advantage/driver of Maven2 was getting the
IDEs configured easily and the project sites... though Hudson has
eroded the project site benifts.

-Stephen

On Dec 12, 2007 2:28 PM, nicolas de loof <[hidden email]> wrote:

> I'm using the " getResource("").getFile() " -> target/test-classes
> workaround,
> but TOO MANY of my test classes use Files and assume the basedir to be the
> maven project root.
>
> This is a coding mistake, but I was searching for a global workaround on
> hudson side.
>
> 2007/12/12, Stephen Connolly <[hidden email]>:
> >
> >
> >
> > public class MyTest // extends TestCase // if using JUnit 3.x
> > {
> >   @Test
> >   public void testSomething() {
> >     Properties config = new Properties();
> >     config.load(getClass().getResourceAsStream("/xxx"));
> >   }
> > }
> >
> > That way you don't assume anything about the current directory, only
> > that test resources will be loaded by the same classloader as the test
> > classes.
> >
> > If you still would rather get at the files directly...
> >
> > getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
> >
> > returns the url of the test class, unless you are running your tests
> > in a very strange way, this url should either be
> > "jar:file:path/to/test-classes.jar!test.package.MyClass.class"
> > or
> > "file:path/to/test-classes/test/package/MyClass.class"
> >
> > It is trivial to extract the test-classes path from either of these...
> > but given that you can package up test classes into a jar file your
> > best technique is to use getResource or getResourceAsStream to access
> > the resources directly.
> >
> > -Stephen
> >
> > On Dec 12, 2007 11:42 AM, nicolas de loof < [hidden email]> wrote:
> > > When I build my maven 2 project, the current directory is the project
> base
> > > directory, so that I can refer to test resources as
> > > new File( "target/test-classes/xxx" );
> > >
> > > When running on hudson, current directory is my HUDSON_HOME (or maybe my
> > > user home, they are same).
> > >
> > > Is there a workaround to avoid this ?
> > >
> > > Nico.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

jblack
In reply to this post by nicolas de loof
I agree 100% with Stephen on this.  I would suggest just biting the bullet and fixing the problem in your code.  Maybe your IDE can do an automatic search/replace refactor for you?


Jeff


nicolas de loof-3 wrote
I'm using the " getResource("").getFile() " -> target/test-classes
workaround,
but TOO MANY of my test classes use Files and assume the basedir to be the
maven project root.

This is a coding mistake, but I was searching for a global workaround on
hudson side.

2007/12/12, Stephen Connolly <stephen.alan.connolly@gmail.com>:
>
> public class MyTest // extends TestCase // if using JUnit 3.x
> {
>   @Test
>   public void testSomething() {
>     Properties config = new Properties();
>     config.load(getClass().getResourceAsStream("/xxx"));
>   }
> }
>
> That way you don't assume anything about the current directory, only
> that test resources will be loaded by the same classloader as the test
> classes.
>
> If you still would rather get at the files directly...
>
> getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
>
> returns the url of the test class, unless you are running your tests
> in a very strange way, this url should either be
> "jar:file:path/to/test-classes.jar!test.package.MyClass.class"
> or
> "file:path/to/test-classes/test/package/MyClass.class"
>
> It is trivial to extract the test-classes path from either of these...
> but given that you can package up test classes into a jar file your
> best technique is to use getResource or getResourceAsStream to access
> the resources directly.
>
> -Stephen
>
> On Dec 12, 2007 11:42 AM, nicolas de loof <nicolas@apache.org> wrote:
> > When I build my maven 2 project, the current directory is the project
> base
> > directory, so that I can refer to test resources as
> > new File( "target/test-classes/xxx" );
> >
> > When running on hudson, current directory is my HUDSON_HOME (or maybe my
> > user home, they are same).
> >
> > Is there a workaround to avoid this ?
> >
> > Nico.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@hudson.dev.java.net
> For additional commands, e-mail: users-help@hudson.dev.java.net
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

jblack
In reply to this post by nicolas de loof
Also, speaking of maven and classpaths, version 2.0.8 of maven has made a significant change in the ordering of the building classpath and testing classpath.

  Changes that may affect existing builds
    * MNG-3118 - Test-classes should come before classes in the classpath. This may slightly alter behavior of tests. The test-classes is now included first in the classpath to allow test resources to override normal runtime ones.

http://maven.apache.org/release-notes.html

Jeff

nicolas de loof-3 wrote
I'm using the " getResource("").getFile() " -> target/test-classes
workaround,
but TOO MANY of my test classes use Files and assume the basedir to be the
maven project root.

This is a coding mistake, but I was searching for a global workaround on
hudson side.

2007/12/12, Stephen Connolly <stephen.alan.connolly@gmail.com>:
>
> public class MyTest // extends TestCase // if using JUnit 3.x
> {
>   @Test
>   public void testSomething() {
>     Properties config = new Properties();
>     config.load(getClass().getResourceAsStream("/xxx"));
>   }
> }
>
> That way you don't assume anything about the current directory, only
> that test resources will be loaded by the same classloader as the test
> classes.
>
> If you still would rather get at the files directly...
>
> getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
>
> returns the url of the test class, unless you are running your tests
> in a very strange way, this url should either be
> "jar:file:path/to/test-classes.jar!test.package.MyClass.class"
> or
> "file:path/to/test-classes/test/package/MyClass.class"
>
> It is trivial to extract the test-classes path from either of these...
> but given that you can package up test classes into a jar file your
> best technique is to use getResource or getResourceAsStream to access
> the resources directly.
>
> -Stephen
>
> On Dec 12, 2007 11:42 AM, nicolas de loof <nicolas@apache.org> wrote:
> > When I build my maven 2 project, the current directory is the project
> base
> > directory, so that I can refer to test resources as
> > new File( "target/test-classes/xxx" );
> >
> > When running on hudson, current directory is my HUDSON_HOME (or maybe my
> > user home, they are same).
> >
> > Is there a workaround to avoid this ?
> >
> > Nico.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@hudson.dev.java.net
> For additional commands, e-mail: users-help@hudson.dev.java.net
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

jblack
In reply to this post by stephenconnolly
"though Hudson has eroded the project site benifts."

I prefer the maven site and reporting plugins to hudson's.  I setup a hudson job to generate and deploy the maven site nightly.  Rational being that I want the developers to have access to the same functionality as CI so we can reproduce all behaviors (for debugging for example).  Plus, one less setup step if I don't have to setup hudson to do it, too.

Jeff


Stephen Connolly-2 wrote
Yeah, we had about 1700 unit tests that made exactly the same
mistake... only they assumed a custom directory layout, they modified
the original source files (so you had to revert to SCM after running
the unit tests), oh and the ant build script was buggy beyond belief,
recursively building one project 34 times just to make a release (to
be sure to be sure)... When I moved to Maven2 as a build process it
took me about a day to fix it though and now at least it's portable
even if we were to move away from Maven. (our build is now down to 54
minutes from 6-8 hours too)

In fairness to ant, it was more that the original build script was a
load of manure.  The main advantage/driver of Maven2 was getting the
IDEs configured easily and the project sites... though Hudson has
eroded the project site benifts.

-Stephen

On Dec 12, 2007 2:28 PM, nicolas de loof <nicolas@apache.org> wrote:
> I'm using the " getResource("").getFile() " -> target/test-classes
> workaround,
> but TOO MANY of my test classes use Files and assume the basedir to be the
> maven project root.
>
> This is a coding mistake, but I was searching for a global workaround on
> hudson side.
>
> 2007/12/12, Stephen Connolly <stephen.alan.connolly@gmail.com>:
> >
> >
> >
> > public class MyTest // extends TestCase // if using JUnit 3.x
> > {
> >   @Test
> >   public void testSomething() {
> >     Properties config = new Properties();
> >     config.load(getClass().getResourceAsStream("/xxx"));
> >   }
> > }
> >
> > That way you don't assume anything about the current directory, only
> > that test resources will be loaded by the same classloader as the test
> > classes.
> >
> > If you still would rather get at the files directly...
> >
> > getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
> >
> > returns the url of the test class, unless you are running your tests
> > in a very strange way, this url should either be
> > "jar:file:path/to/test-classes.jar!test.package.MyClass.class"
> > or
> > "file:path/to/test-classes/test/package/MyClass.class"
> >
> > It is trivial to extract the test-classes path from either of these...
> > but given that you can package up test classes into a jar file your
> > best technique is to use getResource or getResourceAsStream to access
> > the resources directly.
> >
> > -Stephen
> >
> > On Dec 12, 2007 11:42 AM, nicolas de loof < nicolas@apache.org> wrote:
> > > When I build my maven 2 project, the current directory is the project
> base
> > > directory, so that I can refer to test resources as
> > > new File( "target/test-classes/xxx" );
> > >
> > > When running on hudson, current directory is my HUDSON_HOME (or maybe my
> > > user home, they are same).
> > >
> > > Is there a workaround to avoid this ?
> > >
> > > Nico.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@hudson.dev.java.net
> > For additional commands, e-mail: users-help@hudson.dev.java.net
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@hudson.dev.java.net
For additional commands, e-mail: users-help@hudson.dev.java.net
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

stephenconnolly
I said eroded, not removed.  We still generate the project site, but
it's only really consulted for the dependency analysis.

JUnit, Cobertura, Checkstyle, PMD, CPD, Findbugs, ToDos... these are
all in Hudson for us... not much left in the Maven Site that people
have a constant need for

On Dec 12, 2007 5:08 PM, jblack <[hidden email]> wrote:

>
> "though Hudson has eroded the project site benifts."
>
> I prefer the maven site and reporting plugins to hudson's.  I setup a hudson
> job to generate and deploy the maven site nightly.  Rational being that I
> want the developers to have access to the same functionality as CI so we can
> reproduce all behaviors (for debugging for example).  Plus, one less setup
> step if I don't have to setup hudson to do it, too.
>
> Jeff
>
>
>
>
> Stephen Connolly-2 wrote:
> >
> > Yeah, we had about 1700 unit tests that made exactly the same
> > mistake... only they assumed a custom directory layout, they modified
> > the original source files (so you had to revert to SCM after running
> > the unit tests), oh and the ant build script was buggy beyond belief,
> > recursively building one project 34 times just to make a release (to
> > be sure to be sure)... When I moved to Maven2 as a build process it
> > took me about a day to fix it though and now at least it's portable
> > even if we were to move away from Maven. (our build is now down to 54
> > minutes from 6-8 hours too)
> >
> > In fairness to ant, it was more that the original build script was a
> > load of manure.  The main advantage/driver of Maven2 was getting the
> > IDEs configured easily and the project sites... though Hudson has
> > eroded the project site benifts.
> >
> > -Stephen
> >
> > On Dec 12, 2007 2:28 PM, nicolas de loof <[hidden email]> wrote:
> >> I'm using the " getResource("").getFile() " -> target/test-classes
> >> workaround,
> >> but TOO MANY of my test classes use Files and assume the basedir to be
> >> the
> >> maven project root.
> >>
> >> This is a coding mistake, but I was searching for a global workaround on
> >> hudson side.
> >>
> >> 2007/12/12, Stephen Connolly <[hidden email]>:
> >> >
> >> >
> >> >
> >> > public class MyTest // extends TestCase // if using JUnit 3.x
> >> > {
> >> >   @Test
> >> >   public void testSomething() {
> >> >     Properties config = new Properties();
> >> >     config.load(getClass().getResourceAsStream("/xxx"));
> >> >   }
> >> > }
> >> >
> >> > That way you don't assume anything about the current directory, only
> >> > that test resources will be loaded by the same classloader as the test
> >> > classes.
> >> >
> >> > If you still would rather get at the files directly...
> >> >
> >> >
> >> getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
> >> >
> >> > returns the url of the test class, unless you are running your tests
> >> > in a very strange way, this url should either be
> >> > "jar:file:path/to/test-classes.jar!test.package.MyClass.class"
> >> > or
> >> > "file:path/to/test-classes/test/package/MyClass.class"
> >> >
> >> > It is trivial to extract the test-classes path from either of these...
> >> > but given that you can package up test classes into a jar file your
> >> > best technique is to use getResource or getResourceAsStream to access
> >> > the resources directly.
> >> >
> >> > -Stephen
> >> >
> >> > On Dec 12, 2007 11:42 AM, nicolas de loof < [hidden email]> wrote:
> >> > > When I build my maven 2 project, the current directory is the project
> >> base
> >> > > directory, so that I can refer to test resources as
> >> > > new File( "target/test-classes/xxx" );
> >> > >
> >> > > When running on hudson, current directory is my HUDSON_HOME (or maybe
> >> my
> >> > > user home, they are same).
> >> > >
> >> > > Is there a workaround to avoid this ?
> >> > >
> >> > > Nico.
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [hidden email]
> >> > For additional commands, e-mail: [hidden email]
> >> >
> >> >
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/maven-2-current-directory---tp14293594p14299310.html
> Sent from the Hudson users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

Jean-Baptiste Quenot
Dunno if you're still looking for a clean solution to this, but I
usually use the "basedir"  system property that is set by Maven to be
the location of the project being built.
--
Jean-Baptiste Quenot
http://caraldi.com/jbq/blog/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

Brant Boehmann
In reply to this post by stephenconnolly
Are you getting Checkstyle, PMD, FindBugs, ToDos from Hudson with a native m2 project ?
If so, how?

On Dec 12, 2007 1:25 PM, Stephen Connolly <[hidden email]> wrote:
I said eroded, not removed.  We still generate the project site, but
it's only really consulted for the dependency analysis.

JUnit, Cobertura, Checkstyle, PMD, CPD, Findbugs, ToDos... these are
all in Hudson for us... not much left in the Maven Site that people
have a constant need for

On Dec 12, 2007 5:08 PM, jblack <[hidden email]> wrote:

>
> "though Hudson has eroded the project site benifts."
>
> I prefer the maven site and reporting plugins to hudson's.  I setup a hudson
> job to generate and deploy the maven site nightly.  Rational being that I
> want the developers to have access to the same functionality as CI so we can
> reproduce all behaviors (for debugging for example).  Plus, one less setup
> step if I don't have to setup hudson to do it, too.
>
> Jeff
>
>
>
>
> Stephen Connolly-2 wrote:
> >
> > Yeah, we had about 1700 unit tests that made exactly the same
> > mistake... only they assumed a custom directory layout, they modified
> > the original source files (so you had to revert to SCM after running
> > the unit tests), oh and the ant build script was buggy beyond belief,
> > recursively building one project 34 times just to make a release (to
> > be sure to be sure)... When I moved to Maven2 as a build process it
> > took me about a day to fix it though and now at least it's portable
> > even if we were to move away from Maven. (our build is now down to 54
> > minutes from 6-8 hours too)
> >
> > In fairness to ant, it was more that the original build script was a
> > load of manure.  The main advantage/driver of Maven2 was getting the
> > IDEs configured easily and the project sites... though Hudson has
> > eroded the project site benifts.
> >
> > -Stephen
> >
> > On Dec 12, 2007 2:28 PM, nicolas de loof <[hidden email]> wrote:
> >> I'm using the " getResource("").getFile() " -> target/test-classes
> >> workaround,
> >> but TOO MANY of my test classes use Files and assume the basedir to be
> >> the
> >> maven project root.
> >>
> >> This is a coding mistake, but I was searching for a global workaround on
> >> hudson side.
> >>
> >> 2007/12/12, Stephen Connolly < [hidden email]>:
> >> >
> >> >
> >> >
> >> > public class MyTest // extends TestCase // if using JUnit 3.x
> >> > {
> >> >   @Test
> >> >   public void testSomething() {
> >> >     Properties config = new Properties();
> >> >     config.load(getClass().getResourceAsStream("/xxx"));
> >> >   }
> >> > }
> >> >
> >> > That way you don't assume anything about the current directory, only
> >> > that test resources will be loaded by the same classloader as the test
> >> > classes.
> >> >
> >> > If you still would rather get at the files directly...
> >> >
> >> >
> >> getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
> >> >
> >> > returns the url of the test class, unless you are running your tests
> >> > in a very strange way, this url should either be
> >> > "jar:file:path/to/test- classes.jar!test.package.MyClass.class"
> >> > or
> >> > "file:path/to/test-classes/test/package/MyClass.class"
> >> >
> >> > It is trivial to extract the test-classes path from either of these...
> >> > but given that you can package up test classes into a jar file your
> >> > best technique is to use getResource or getResourceAsStream to access
> >> > the resources directly.
> >> >
> >> > -Stephen
> >> >
> >> > On Dec 12, 2007 11:42 AM, nicolas de loof < [hidden email]> wrote:
> >> > > When I build my maven 2 project, the current directory is the project
> >> base
> >> > > directory, so that I can refer to test resources as
> >> > > new File( "target/test-classes/xxx" );
> >> > >
> >> > > When running on hudson, current directory is my HUDSON_HOME (or maybe
> >> my
> >> > > user home, they are same).
> >> > >
> >> > > Is there a workaround to avoid this ?
> >> > >
> >> > > Nico.
> >> > >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [hidden email]
> >> > For additional commands, e-mail: [hidden email]
> >> >
> >> >
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/maven-2-current-directory---tp14293594p14299310.html
> Sent from the Hudson users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: maven 2 current directory ?

stephenconnolly
The m2 project type is too borked for me.  I just use freestyle, plus
I have more control anyway.

Once I get a chance I will finish the cobertura plugin's m2 support...
then Peter _might_ copy my code into the violations plugin (or I will
copy it in on him!) and there they'll be.

-Stephen

On Dec 14, 2007 3:28 PM, Brant Boehmann <[hidden email]> wrote:

> Are you getting Checkstyle, PMD, FindBugs, ToDos from Hudson with a native
> m2 project ?
> If so, how?
>
>
>
> On Dec 12, 2007 1:25 PM, Stephen Connolly < [hidden email]>
> wrote:
> > I said eroded, not removed.  We still generate the project site, but
> > it's only really consulted for the dependency analysis.
> >
> > JUnit, Cobertura, Checkstyle, PMD, CPD, Findbugs, ToDos... these are
> > all in Hudson for us... not much left in the Maven Site that people
> > have a constant need for
> >
> >
> >
> >
> > On Dec 12, 2007 5:08 PM, jblack <[hidden email]> wrote:
> > >
> > > "though Hudson has eroded the project site benifts."
> > >
> > > I prefer the maven site and reporting plugins to hudson's.  I setup a
> hudson
> > > job to generate and deploy the maven site nightly.  Rational being that
> I
> > > want the developers to have access to the same functionality as CI so we
> can
> > > reproduce all behaviors (for debugging for example).  Plus, one less
> setup
> > > step if I don't have to setup hudson to do it, too.
> > >
> > > Jeff
> > >
> > >
> > >
> > >
> > > Stephen Connolly-2 wrote:
> > > >
> > > > Yeah, we had about 1700 unit tests that made exactly the same
> > > > mistake... only they assumed a custom directory layout, they modified
> > > > the original source files (so you had to revert to SCM after running
> > > > the unit tests), oh and the ant build script was buggy beyond belief,
> > > > recursively building one project 34 times just to make a release (to
> > > > be sure to be sure)... When I moved to Maven2 as a build process it
> > > > took me about a day to fix it though and now at least it's portable
> > > > even if we were to move away from Maven. (our build is now down to 54
> > > > minutes from 6-8 hours too)
> > > >
> > > > In fairness to ant, it was more that the original build script was a
> > > > load of manure.  The main advantage/driver of Maven2 was getting the
> > > > IDEs configured easily and the project sites... though Hudson has
> > > > eroded the project site benifts.
> > > >
> > > > -Stephen
> > > >
> > > > On Dec 12, 2007 2:28 PM, nicolas de loof <[hidden email]> wrote:
> > > >> I'm using the " getResource("").getFile() " -> target/test-classes
> > > >> workaround,
> > > >> but TOO MANY of my test classes use Files and assume the basedir to
> be
> > > >> the
> > > >> maven project root.
> > > >>
> > > >> This is a coding mistake, but I was searching for a global workaround
> on
> > > >> hudson side.
> > > >>
> > > >> 2007/12/12, Stephen Connolly < [hidden email]>:
> > > >> >
> > > >> >
> > > >> >
> > > >> > public class MyTest // extends TestCase // if using JUnit 3.x
> > > >> > {
> > > >> >   @Test
> > > >> >   public void testSomething() {
> > > >> >     Properties config = new Properties();
> > > >> >     config.load(getClass().getResourceAsStream("/xxx"));
> > > >> >   }
> > > >> > }
> > > >> >
> > > >> > That way you don't assume anything about the current directory,
> only
> > > >> > that test resources will be loaded by the same classloader as the
> test
> > > >> > classes.
> > > >> >
> > > >> > If you still would rather get at the files directly...
> > > >> >
> > > >> >
> > > >>
> getClass().getResource("/"+getClass().getName().replace('.','/')+".class")
> > > >> >
> > > >> > returns the url of the test class, unless you are running your
> tests
> > > >> > in a very strange way, this url should either be
> > > >> > "jar:file:path/to/test- classes.jar!test.package.MyClass.class"
> > > >> > or
> > > >> > "file:path/to/test-classes/test/package/MyClass.class"
> > > >> >
> > > >> > It is trivial to extract the test-classes path from either of
> these...
> > > >> > but given that you can package up test classes into a jar file your
> > > >> > best technique is to use getResource or getResourceAsStream to
> access
> > > >> > the resources directly.
> > > >> >
> > > >> > -Stephen
> > > >> >
> > > >> > On Dec 12, 2007 11:42 AM, nicolas de loof < [hidden email]>
> wrote:
> > > >> > > When I build my maven 2 project, the current directory is the
> project
> > > >> base
> > > >> > > directory, so that I can refer to test resources as
> > > >> > > new File( "target/test-classes/xxx" );
> > > >> > >
> > > >> > > When running on hudson, current directory is my HUDSON_HOME (or
> maybe
> > > >> my
> > > >> > > user home, they are same).
> > > >> > >
> > > >> > > Is there a workaround to avoid this ?
> > > >> > >
> > > >> > > Nico.
> > > >> > >
> > > >> >
> > > >> >
> ---------------------------------------------------------------------
> > > >> > To unsubscribe, e-mail: [hidden email]
> > > >> > For additional commands, e-mail: [hidden email]
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [hidden email]
> > > > For additional commands, e-mail: [hidden email]
> > > >
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> http://www.nabble.com/maven-2-current-directory---tp14293594p14299310.html
> > > Sent from the Hudson users mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > >
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...