Generate JARs and build PIT from Source

116 views
Skip to first unread message

Tania Shwee

unread,
Nov 10, 2016, 2:14:35 AM11/10/16
to PIT Users
Hi Everyone,

I cloned the pitest-master repository into my workspace.
How do I generate the various JARs(pitest,pitest-ant,pitest-maven,pitest-command-line) from an ant-style build script.
i wrote a custom build logic which runs ant but I ended up with no JAR files.
Also, since ./configure make make-install could not be run within the package, please let me know how to build from source.
I referred: http://pitest.org/quickstart/ant/ which suggests that for the target "ant pit" to run, the JAR files must be available within lib/.
I surmise that downloading the JARs manually from releases isn't the right approach.
Could you please point me to the right direction?


Thanks,
Tania

Marcin Zajączkowski

unread,
Nov 10, 2016, 2:55:25 AM11/10/16
to pitu...@googlegroups.com
On 2016-11-10 08:14, Tania Shwee wrote:
> Hi Everyone,
>
> I cloned the pitest-master repository into my workspace.
> How do I generate the various *JARs*(pitest,pitest-ant,pitest-maven,pitest-command-line)
> from an ant-style build script.
> i wrote a custom build logic which runs ant but I ended up with no JAR
> files.
> Also, since ./configure make make-install could not be run within the
> package, please let me know how to build from source.
> I referred: http://pitest.org/quickstart/ant/ which suggests that for the
> target* "ant pit"* to run, the JAR files must be available within lib/.
> I surmise that downloading the JARs manually from releases isn't the right
> approach.
> Could you please point me to the right direction?

Have you tried the standard Maven approach?

mvn package
(in the root project directory)

It should download all required dependencies, compile code, run tests
and generate JAR files (located in the corresponding target directories).

Marcin

--
http://blog.solidsoft.info/ - Working code is not enough

Marcin Zajączkowski

unread,
Nov 10, 2016, 3:09:48 AM11/10/16
to pitu...@googlegroups.com
This qs the direct answer to your question, however, it is only suitable
if you want to add your own changes to PIT (and build them to test
locally) or have any other reason to play with PIT development.

For the regular usage it is enough to have Maven, Gradle or Sbt, add PIT
plugin, configure it and run analysis as described on the proper subpage
of http://pitest.org/quickstart/ . Everything (including transitive
dependencies) should be downloaded automatically from Maven Central.

In the end, I'm not sure what would you like to achieve in the end...

Shriya Venkatesh

unread,
Nov 10, 2016, 3:10:07 AM11/10/16
to pitu...@googlegroups.com, Marcin Zajączkowski
I did. here's the exception I got:

Exception in thread "main" java.lang.NoClassDefFoundError: org/sonatype/aether/transfer/AbstractTransferListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.getEnhancedMainMethod(Launcher.java:173)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:269)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.transfer.AbstractTransferListener
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
        ... 23 more

perhaps I need to model my ANT config file to manually depend on the missingpackage(sonar)?



--
You received this message because you are subscribed to a topic in the Google Groups "PIT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pitusers/iGfena6rW8Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pitusers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shriya Venkatesh

unread,
Nov 10, 2016, 3:13:48 AM11/10/16
to pitu...@googlegroups.com
Makes sense. I am only taking PIT as a dependency for one of my packages. I was guessing if there was a way to automatically Make the JARS from source
rather than having to download the latest pitest and pitest-ant jars manually as the tutorials suggested.


Marcin Zajączkowski

unread,
Nov 10, 2016, 5:11:53 AM11/10/16
to pitu...@googlegroups.com
On 2016-11-10 09:10, Shriya Venkatesh wrote:
> I did. here's the exception I got:

What exactly did you do?

This class is used by Maven. Do you try to call it from Ant?

Marcin
>> pitusers+u...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>


Shriya Venkatesh

unread,
Nov 10, 2016, 6:25:38 AM11/10/16
to pitu...@googlegroups.com
I tried running mvn(through a third party Maven plugin) and got this:

[INFO] Reactor Summary:
[INFO] 
[INFO] pitest-parent ..................................... SUCCESS [0.004s]
[INFO] Build Config ...................................... FAILURE [1.876s]
[INFO] pitest ............................................ SKIPPED
[INFO] pitest-html-report ................................ SKIPPED
[INFO] pitest-maven ...................................... SKIPPED
[INFO] pitest-command-line ............................... SKIPPED
[INFO] pitest-ant ........................................ SKIPPED
[INFO] pitest-maven-verification ......................... SKIPPED
[INFO] pitest-java8-verification ......................... SKIPPED
[INFO] pitest-groovy-verification ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.177s
[INFO] Finished at: Thu Nov 10 03:19:30 PST 2016
[INFO] Final Memory: 62M/187M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.6 -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.6
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:140)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
        at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecution(DefaultLifecycleExecutionPlanCalculator.java:152)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecutions(DefaultLifecycleExecutionPlanCalculator.java:139)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:116)
        at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan(DefaultLifecycleExecutionPlanCalculator.java:129)
        at org.apache.maven.lifecycle.internal.BuilderCommon.resolveBuildPlan(BuilderCommon.java:92)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Could not find artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.6
the Exception in thread "main" java.lang.NoClassDefFoundError: org/sonatype/aether/transfer/AbstractTransferListener exception went away when I tried the third party maven plugin.
Just to be sure, is "mvn package" the preferred way to create JARs here? I guess I will have to look into my configurations here. Looks like Maven is not able to download the plugins from an external repository. Any hints/ Red herrings?


>> For more options, visit https://groups.google.com/d/optout.
>>
>


--
http://blog.solidsoft.info/ - Working code is not enough

--
You received this message because you are subscribed to a topic in the Google Groups "PIT Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pitusers/iGfena6rW8Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pitusers+unsubscribe@googlegroups.com.

Marcin Zajączkowski

unread,
Nov 10, 2016, 6:42:31 AM11/10/16
to pitu...@googlegroups.com
What version of Maven do you use? Please try with the newest one.

https://maven.apache.org/download.cgi

Marcin
> the *Exception in thread "main" java.lang.**NoClassDefFoundError:
> org/sonatype/aether/transfer/**AbstractTransferListener *exception went
>>>> pitusers+u...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>
>>
>> --
>> http://blog.solidsoft.info/ - Working code is not enough
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "PIT Users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/pitusers/iGfena6rW8Y/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> pitusers+u...@googlegroups.com.

Henry Coles

unread,
Nov 10, 2016, 8:16:54 AM11/10/16
to pitu...@googlegroups.com
Hi Shirya,

Pitest follows the standard maven conventions. Jars can be built with

mvn package

They can be installed into your local m2 cache with

mvn install

It looks like there is an issue with your maven installation or configuration. My best guess is that maven is either unable to connect to maven central (the standard store of jar dependencies) or has been configured not to look in it, although the error message is not quite what I would expect if that were the case.

I suggest you try building another simple maven project and see if that works - you may be able to get better help with general maven issues at the maven mailing list than you will here.

You should only need to build the pitest jars yourself if you have made a local modification to the source. To simply use pitest it is far easier to download the jars yourself (if you are using ant), or allow the build system to resolve them for you (if you are using maven or gradle).

Your earlier idea of building pitest using Ant will not work. The pitest build needs to do more than simply compile and package the source (for example it relocates classes from the ASM project into a different namespace). Recreating all the work performed by the maven pom in Ant would be a large task.

Henry

You received this message because you are subscribed to the Google Groups "PIT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pitusers+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages