testReport destinationDir is deprecated in gradle 7.4.2 so how to set it? - gradle

task<TestReport>("testReport") {
destinationDir = file("$buildDir/reports/allTests")
}
This is apparently deprecated, but the deprecation message doesn't make sense to me in this context. How am I actually supposed to set this value now?
/**
* Sets the directory to write the HTML report to.
*
* <strong>This method will be {#code #Deprecated} soon, please use {#link #getTestResults()} instead to access the new collection property.</strong>
*/
public void setDestinationDir(File destinationDir) {
DeprecationLogger.deprecateProperty(TestReport.class, "destinationDir").replaceWith("destinationDirectory")
.willBeRemovedInGradle8()
.withDslReference()
.nagUser();
getDestinationDirectory().set(destinationDir);
}

Please try like this.
Older version:
destinationDir = file("$buildDir/reports/tests/test")
With latest version:
getDestinationDirectory().set(file("$buildDir/reports/tests/test"))
It worked for me. Hope it'll work for you. Thanks

Related

Karate-afterFeature - main feature file cannot call another feature file using Karate-afterFeature

I have a problem with Karate afterFeature configuration.
I want to call a clean up step from a separate feature file after every scenario. Hence, I configured a afterFeature js function, that should call that cleanup feature using karates call function.
The callonce works fine in prior step, but I have problem with the afterFeature.
This is the code how I configure afterFeature:
* def result = callonce read('../callOnceCreateCompanyForBrowse.feature')
* def id = result.response.data.createCompanyEvent.id
* configure afterFeature = function(){ karate.call('../../deleteCompanyEvent.feature', {id : id}); }
Suggestion, instead of relative paths (which is hard to get right) use the classpath: prefix.
* configure afterFeature = function(){ karate.call('classpath:com/myco/deleteCompanyEvent.feature', { id: id }) }
EDIT: looks like the solution was using a runner instead of running the feature directly.

Is there a way to easily only allow a subset of azure functions to run when debugging locally in Visual Studio?

I'm using Visual Studio to write a class library which contains several Azure functions. There is a combination of timer and queue triggered functions. If I'm working on one of the functions and want to debug only it I have to comment out the other functions to keep them also from executing. Is there a way to easily indicate that I only want a subset of the entire set of functions to execute when debugging locally?
You can configure which functions to load in your host.json (full spec here.) Specifically, you'll want to define a top-level functions property:
{
"functions": [ "QueueProcessor", "GitHubWebHook" ]
}
(Note this is only meant for local use; you'll want to use the function.json disabled property for published functions.)
You could make use of the Disable() attribute, however, that's not much better than commenting out code:
public static void Run([TimerTrigger("0 */5 * * * *"), Disable()]TimerInfo myTimer, TraceWriter log)
You could combine the Disable() attribute with #if directive, but it clutters up your code. The Disable() attribute will only be applied if DEBUG is defined.
The following function will run if in release mode, and is disabled if in debug mode.
[FunctionName("TimerFunction")]
public static void Run([
#if DEBUG
TimerTrigger("*/5 * * * * *"), Disable()
#else
TimerTrigger("*/5 * * * * *")
#endif
]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
}
You can decorate your function with a DisableAttribute controlled by a settingName from the local.settings.json file.
The following is an example:
[QueueTrigger("%queueName%", Connection = "queues"), Disable("MyFuncABC")]ProcessMessage msg,

How to configure Gradle TestNGOptions in a custom plugin written in Java?

I'm writing a custom Gradle plugin that will create a new Test task and run it. I need to set some configuration on this test task.
The plugin is written in Java and the code to execute the Test task looks like this:
private void runSmokeTests() {
Test test = new Test();
test.useTestNG(new Closure(/* What goes in here? */) {
// and here? How do I get hold of TestNGOptions?
});
test.executeTests();
}
I can't figure out how to use the Closure class from Java.
Simplest option is just to call getOptions() and cast to the appropriate type.
test.useTestNG();
TestNGOptions options = (TestNGOptions) test.getOptions();
// configure options ie...
options.setPreserveOrder(true);

How to update the <latest> tag in maven-metadata-local when installing an artifact?

In the project I am working on we have various multi-module projects being developed in parallel, some of which are dependent on others. Because of this we are using using version ranges, e.g. [0.0.1,), for our internal dependencies during development so that we can always work against the latest snapshot versions. (I understand that this isn't considered best practice, but for now at least we are stuck with the current project structure.) We have build profiles set up so that when we perform a release all the version ranges get replaced with RELEASE to compile against the latest released version.
We have to use ranges as opposed to LATEST because when installing an artifact locally, the <latest> tag inside maven-metadata-local.xml is never updated, and so specifying LATEST will get the last version deployed to our Artifactory server. The problem with the ranges though is that the build process seems to have to download all the metadata files for all the versions of an artifact to be able to determine the latest version. As our project goes on we are accumulating more and more versions and artifacts so our builds are taking longer and longer. Specifying LATEST avoids this but means that changes from local artifact installs are generally not picked up.
Is there any way to get the <latest> tag in the maven-metadata-local.xml file to be updated when installing an artifact locally?
If you are working with SNAPSHOT's you don't need version ranges apart from that never use version ranges (only in extrem rare situtions). With version ranges your build is not reproducible which should be avoided in my opinion under any circumstance.
But you can use things like this:
<version>[1.2.3,)</version
but as you already realized that caused some problems, but I would suggest to use the versions-maven-plugin as an alternative to update the projects pom files accordingly.
mvn clean versions:use-latest-versions scm:checkin deploy -Dmessage="update versions" -DperformRelease=true
This can be handled by CI solution like Jenkins. But I got the impression that you are doing some basic things wrong. In particular if you need to use version ranges.
I had the same problem, so I wrote a maven plugin to handle it for me. It's a pretty extreme workaround, but it does work.
The documentation for creating maven plugins is on The Apache Maven Project. You could just create a plugin project from the command line archetype and add this mojo to your project.
/**
* Inserts a "latest" block into the maven-metadata-local.xml in the user's local
* repository using the currently configured version number.
*
* #version Sep 23, 2013
*/
#Mojo( name = "latest-version", defaultPhase = LifecyclePhase.INSTALL )
public class InstallLatestVersionMojo extends AbstractMojo {
/**
* Location of the .m2 directory
*/
#Parameter( defaultValue = "/${user.home}/.m2/repository", property = "outputDir", required = true )
private File repositoryLocation;
#Parameter( defaultValue = "${project.groupId}", property = "groupId", required = true )
private String groupId;
#Parameter( defaultValue = "${project.artifactId}", property = "artifactId", required = true )
private String artifactId;
/**
* Version to use as the installed version
*/
#Parameter( defaultValue = "${project.version}", property = "version", required = true )
private String version;
public void execute() throws MojoExecutionException, MojoFailureException {
try {
// Fetch the xml file to edit from the user's repository for the project
File installDirectory = getInstallDirectory(repositoryLocation, groupId, artifactId);
File xmlFile = new File(installDirectory, "maven-metadata-local.xml");
Document xml = getXmlDoc(xmlFile);
if (xml != null) {
// Fetch the <latest> node
Node nodeLatest = getNode(xml, "/metadata/versioning/latest");
if (nodeLatest == null) {
// If <latest> does not yet exist, insert it into the <versioning> block before <versions>
nodeLatest = xml.createElement("latest");
Node versioningNode = getNode(xml, "/metadata/versioning");
if (versioningNode != null) {
versioningNode.insertBefore(nodeLatest, getNode(xml, "metadata/versioning/versions"));
}
}
// set the version on the <latest> node to the newly installed version
nodeLatest.setTextContent(version);
// save the xml
save(xmlFile, xml);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void save(File xmlFile, Document xml) throws TransformerFactoryConfigurationError, TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
Result output = new StreamResult(xmlFile);
Source input = new DOMSource(xml);
transformer.transform(input, output);
}
private Node getNode(Document source, String path) throws XPathExpressionException{
Node ret = null;
XPathExpression xPath = getPath(path);
NodeList nodes = (NodeList) xPath.evaluate(source, XPathConstants.NODESET);
if(nodes.getLength() > 0 ) {
ret = nodes.item(0);
}
return ret;
}
private XPathExpression getPath(String path) throws XPathExpressionException{
XPath xpath = XPathFactory.newInstance().newXPath();
return xpath.compile(path);
}
private File getInstallDirectory(File repositoryLocation, String groupId, String artifactId) {
String group = groupId.replace('.', '/');
return new File(repositoryLocation, group + "/" + artifactId);
}
private Document getXmlDoc(File xmlFile) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
return dBuilder.parse(xmlFile);
}
}
How about defining those internal dependencies as modules in one reactor pom? That way you'll compile against the compiled sources (in target/classes) instead of against a jar, and you'll always have the latest code.

Error with undefined method CI_Loader::plugin()

I received the following error:
Call to undefined method CI_Loader::plugin() in C:\wamp\www\Code\application\libraries\DX_Auth.php on line 1233
on this code:
function captcha()
{
$this->ci->load->helper('url');
$this->ci->load->plugin('dx_captcha');
$captcha_dir = trim($this->ci->config->item('DX_captcha_path'), './');
Make sure you have moved any array values in application/config/autoload.php from $autoload[‘plugins’] to $autoload[‘helpers’] or you will notice stuff break.
This is the reference
Which version of CI are you using? Plugins has been removed since the 2.x and replaced with helper.
Try to use reCaptcha instead, it has a good library.
You're trying to load a plugin and plugins are not supported, if I remember it right since CI version 2. If that's the case (which seems to be) you need to convert your plugins into helpers.
I think you are trying to use an old version of DX_Auth on new version of CodeIgniter. Current version of DX_Auth is compatible with CI 2.x and is available on github.
A simple way to solve this problem is that you just put this code in your loader.php. The plugin its works. Go to System->Core->Loader.php.
/**
* Load Plugin
*
* This function loads the specified plugin.
*
* #access public
* #param array
* #return void
*/
function plugin($plugins = array())
{
if ( ! is_array($plugins))
{
$plugins = array($plugins);
}
foreach ($plugins as $plugin)
{
$plugin = strtolower(str_replace(EXT, '', str_replace('_pi', '', $plugin)).'_pi');
if (isset($this->_ci_plugins[$plugin]))
{
continue;
}
if (file_exists(APPPATH.'plugins/'.$plugin.EXT))
{
include_once(APPPATH.'plugins/'.$plugin.EXT);
}
else
{
if (file_exists(BASEPATH.'plugins/'.$plugin.EXT))
{
include_once(BASEPATH.'plugins/'.$plugin.EXT);
}
else
{
show_error('Unable to load the requested file: plugins/'.$plugin.EXT);
}
}
$this->_ci_plugins[$plugin] = TRUE;
log_message('debug', 'Plugin loaded: '.$plugin);
}
}
// --------------------------------------------------------------------
/**
* Load Plugins
*
* This is simply an alias to the above function in case the
* user has written the plural form of this function.
*
* #access public
* #param array
* #return void
*/
function plugins($plugins = array())
{
$this->plugin($plugins);
}

Resources