I need to depend on a JAR file that contains the entire JUnit 3 package, but I bundle JUnit 4 separately with my project. Hence, my test break because they are executed using the JUnit 3 runner, when they should instead be run using the JUnit 4 runner.
The question is: can I tell Gradle to not include certain classes or entire packages from a JAR when depending on it?
UPDATE
It worked using the suggested zipTree/copy solution:
task processAndroidJar(type: Copy) {
from zipTree("$androidHome/platforms/android-8/android.jar")
into "$buildDir/android"
exclude "junit/**"
}
compileJava.dependsOn processAndroidJar
dependencies {
compile files("$buildDir/android")
}
Works beautifully.
You can try to depend on jar file as a ZipTree
ZipTree allows you to include/exclude different paths within archive in your dependency
Related
I have a Premake 5 project that builds a static library (primarily via the gmake2 or vs2017 actions). I'd like to create a build target for the release material itself: the library zipped up with some text and header files.
How do I do this with Premake? I tried something like:
project "thing_export"
kind "Utility"
os.mkdir "Release"
-- etc
...but of course the os... functions are executed when Premake runs, they don't end up in the build files.
I also tried using custom build commands:
project "thing_export"
kind "Utility"
buildmessage "Creating release"
buildcommands { "{copy} README.md '%{prj.location}'" }
buildoutputs { "'%{prj.location}/README.md'" }
The makefile generated by the gmake or gmake2 actions is the same as for an empty project. No actions are generated for it.
How can I use Premake to create my releases?
Depending on what you need to do, you might be able to make that approach work. What I usually do (and what Premake itself does) is write a Lua script to automate the release packaging, and use a custom Premake action to run it.
Have a look at Premake's package.lua script to see how it automates the packaging. And here is the custom action that calls package.lua:
newaction {
trigger = "package",
description = "Creates source and binary packages",
execute = function ()
include (path.join(corePath, "scripts/package.lua"))
end
}
When I open my cordapp-example in intellj. I can see 2 build.gradle files.
One under java-source and another in the cordapp-example directory i.e main director. What is the difference between both of them?
This is a result of the way gradle works for managing multiple separate modules within one top level project. In this case, the cordapp-example has a java version and kotlin version - both have their own build settings and dependencies. The top level build.gradle has configuration and dependencies which are applied to both projects.
You can see that settings.gradle contains the following:
include 'kotlin-source'
include 'java-source'
This defines the submodules included in the project.
I have a simple sbt application that uses typesafe-config library and is build using sbt-native-packager.
I build it using following command:
sbt universal:packageBin
Within the src directory I have following hierarchy:
main/resources/application.conf
test/resources/application.conf
staging/resources/application.conf
And my archive always ends up containing only the main version of application.conf
I'm looking for a easy way to include specific application.conf file based on for example java property passed during project build, but I'm unable to find anything.
Have you taken a look at the mappings facility, which allows you to add/remove files from the base layout? See Change-Remove Top Level Directory In Output in the official docs.
I've got 3 project defined in my Build.scala file:
common
services.dependsOn(common)
web.dependsOn(common)
Project Common contains /test/resources with logback-test.xml configuration which I would like to use for services and web tests.
This setup works fine in intelliJ with sbt-idea but when I try to run 'sbt test' from command line the logback-test.xml isn't copied over to /services/target/testClasses or /web/target/testClasses which means that the tests will use default slf4j configuration with useless tons of DEBUG info.
What should I do to force sbt to copy test resources from dependent project to others.
Thanks in advance
Dependencies don't include test configuration by default. You can change this like so:
common
services.dependsOn(common % "compile->compile;test->test")
web.dependsOn(common % "compile->compile;test->test")
More info here
I would like to run some unit Tests individually with PHPUnit, but I have certain classes separated from the Tests, since I am using the symfony framework, and I group the Tests and the Classes in different folders.
I would like to run the Tests individually like this:
php phpunit.phar MyTest.php
The problem is that the test file uses the classes from the controllers, and phpunit doesnt seem to be able to import the needed classes for the test.
This is not a problem to run all the tests together, thanks to phpunit.xml but when I want to run them individualy, its a problem.
How could I fix this?
You have to point phpunit where you have your phpunit.xml config file (because it must know the autoloader for example). If you have default symfony 2 structure it will be in app directory, so just run your test like that (I assume that you are in project root path):
phpunit -c app/ --filter="concreteTestPattern" src/Acme/DemoBundle/Tests/MyTest.php
edit:
Above will run all tests which names match to the pattern: /.*concreteTestPattern.*/
You would use the --filter argument in your PHPUnit command string. This will only run tests that match the pattern given. If you pass only the complete name of the test that you want run, phpunit should only run that test.
If you have a data provider associated with the test and only want to run one test case, you can also filter that by using --filter <testName>::<testcase name>
PHPUnit can be set to execute using a configuration file.
In our Symfony2 project this file is located at app/phpunit.xml.dist.
As this file is suffixed with .dist, you need to copy its contents into a file called app/phpunit.xml.
If you are using a VCS such as Git, you should add the new app/phpunit.xml file to the VCS ignore list.
You will also notice the configuration is specifying the bootstrap file located at app/bootstrap.php.cache. This file is used by PHPUnit to get the testing environment setup.
We can execute this test by running the following command from the root directory of the project. The -c option specifies that PHPUnit should load its configuration from the app directory.
$ phpunit -c app