Cucumber + JUnit5: No tests found for given includes - cucumber

I'm using Cucumber and JUnit5 to write tests for my projects. My project uses Spring Framework and Gradle as a build tool and I use IntelliJ Idea as an editor which has Cucumber and Gradle plugins. Here is my Cucumber's runner:
package com.mycom.myproject.cucumber;
import static io.cucumber.junit.platform.engine.Constants.*;
import org.junit.platform.suite.api.*;
#Suite
#IncludeEngines("cucumber")
#SelectClasspathResource("src/test/resources")
#ConfigurationParameters({
#ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.mycom.myproject.cucumber.steps"),
#ConfigurationParameter(key = FEATURES_PROPERTY_NAME, value = "src/test/resources/cucumber"),
#ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "html")
})
public class RunCucumberTest {
}
This is my cucumberBootstrap class:
package com.mycom.myproject.cucumber;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import com.mycom.myproject.Application;
import io.cucumber.spring.CucumberContextConfiguration;
#CucumberContextConfiguration
#SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, args = "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,com.arkea.catalyst.kafka.spring.KafkaAutoConfiguration")
#ActiveProfiles({ "IC" })
public class CucumberBootstrap {
}
My steps definition class:
package com.mycom.myproject.cucumber.steps;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class StepDefinition extends CucumberBootstrap {
#Quand("I want to calculate my bill")
public void iWantToCalculateMyBill() {
// some code
}
#Alors("I have this result")
public void iHaveThisResult() {
// some assertions
}
}
Here is my gradle.build file:
// Tests dependencies
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'io.rest-assured:rest-assured:4.1.2'
testImplementation "io.cucumber:cucumber-java:$cucumberVersion"
testImplementation "io.cucumber:cucumber-spring:$cucumberVersion"
testImplementation "io.cucumber:cucumber-junit-platform-engine:$cucumberVersion"
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation 'org.junit.platform:junit-platform-suite:1.9.0'
implementation 'org.junit.platform:junit-platform-commons:1.9.0'
}
test {
useJUnitPlatform()
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
My cucumber's version is 7.5.0.
No matter how I change the code, I keep having the "no tests found for given includes" error and I have no idea how to change it.
Do you guys have any clue?
Thanks

In your runner class you've got two problems.
Problem 1
#SelectClasspathResource("src/test/resources")
This selects a classpath resource. However src/test/resources is not a resource on the classpath.
To explain, consider a simple project you may have the following layout:
src
├── main
│   └── java
│   └── io
│   └── cucumber
│   └── skeleton
│   └── Belly.java
└── test
├── java
│   └── io
│   └── cucumber
│   └── skeleton
│   ├── RunCucumberTest.java
│   └── StepDefinitions.java
└── resources
├── io
│   └── cucumber
│   └── skeleton
│   └── belly.feature
└── junit-platform.properties
Here src/main/java, src/test/java and src/test/resources are different sources. When you build your project these are compiled or copied the build folder:
build
├── classes
│   └── java
│   ├── main
│   │   └── io
│   │   └── cucumber
│   │   └── skeleton
│   │   └── Belly.class
│   └── test
│   └── io
│   └── cucumber
│   └── skeleton
│   ├── RunCucumberTest.class
│   └── StepDefinitions.class
└── resources
└── test
├── io
│   └── cucumber
│   └── skeleton
│   └── belly.feature
└── junit-platform.properties
Then when running your tests, the class path is composed of your dependencies and the build/classes/java/{main,test} and build/resources/test classpath roots.
This means that io/cucumber/{Belly,RunCucumberTest,StepDefinitions}.class as well as io/cucumber/skeleton/belly.feature are all resources on the classpath.
And because #SelectClasspathResource selects a class path resource you should use #SelectClasspathResource("io/cucumber/skeleton/belly.feature"). If you have multiple features in #SelectClasspathResource("io/cucumber/skeleton") will also work.
Problem 2
#ConfigurationParameter(key = FEATURES_PROPERTY_NAME, ..)
The FEATURES_PROPERTY_NAME only exists because Maven and Gradle don't support JUnit5s discovery selectors from the command line. You don't need it in this case.

Related

Autotools Makefile cannot find sources

I am trying to use autotools in my Yocto project. Working with another user I was able to get bitbake to recognize my autogen.sh, configure.ac and Makefile.am. I am now getting the error
make: *** No rule to make target 'main.c', needed by 'main.o'. Stop.
My tree is as follows:
.
├── files
│   ├── MAIN_Application
│   │   ├── autogen.sh
│   │   ├── configure.ac
│   │   ├── include
│   │   │   ├── main.h
│   │   │   ├── scheduler.h
│   │   │   └── utilities
│   │   │   └── time_conversions.h
│   │   ├── Makefile.am
│   │   ├── project.yml
│   │   └── src
│   │   ├── main.c
│   │   ├── Makefile.am
│   │   ├── scheduler.c
│   │   └── utilities
| | ├── Makefile.am
│   │   └── time_conversions.c
│   └── services
│   └── mainapplication.service
└── mainapplication_0.0.bb
My makefile.am is as follows:
AUTOMAKE_OPTIONS = foreign
CFLAGS = -Wall -pedantic -O2
include_HEADERS = main.h
bin_PROGRAMS = MAIN_Application
MAIN_Application_SOURCES = main.c
I believe I need to add my other source files. What I am not sure is how to do so. Do I add them with MAIN_Application_SOURCES or do I need to add a Makefile.am in each subdirectory?
Edit: Adding link to previous question.
Edit 2: I have added a makefile.am to each directory. In MAIN_Application I have:
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
In src I have:
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = MAIN_Application
EVCC_Application_SOURCES = main.c scheduler.c time_conversions.c
This gives a new error:
| Making all in src
| /bin/bash: line 20: cd: src: No such file or directory
| make: *** [Makefile:332: all-recursive] Error 1
| ERROR: oe_runmake failed
Edit 3: If I remove my src and include folders, place everything into one folder (top level) it all works. This is ugly and I hate it.
.
├── files
│   ├── MAIN_Application
│   │   ├── autogen.sh
│   │   ├── configure.ac
│   │   ├── main.c
│   │   ├── main.h
│   │   ├── Makefile.am
│   │   ├── project.yml
│   │   ├── scheduler.c
│   │   ├── scheduler.h
│   │   ├── time_conversions.c
│   │   └── time_conversions.h
│   └── services
│   └── mainapplication.service
└── mainapplication_0.0.bb
There has to be a way around this.
Edit 4: I am attempting to move all of my code into a src directory and use SUBDIR in my makefile.am
.
├── files
│   ├── MAIN_Application
│   │   ├── autogen.sh
│   │   ├── configure.ac
│   │   ├── include
│   │   ├── Makefile.am
│   │   ├── project.yml
│   │   ├── src
│   │   │   ├── main.c
│   │   │   ├── main.h
│   │   │   ├── Makefile.am
│   │   │   ├── scheduler.c
│   │   │   ├── scheduler.h
│   │   │   ├── time_conversions.c
│   │   │   └── time_conversions.h
│   │   └── test
│   │   ├── test_scheduler.c
│   │   └── test_time_conversions.c
│   └── services
│   └── mainapplication.service
└── mainapplication_0.0.bb
This leads to the same error of src no such file or directory.
I believe I need to add my other source files. What I am not sure is how to do so.
There is more than one way to do it, but one way or another, yes, you do need to tell Automake about all the sources involved. Depending on how you do it, you might need more than to just designate the sources.
Do I add them with MAIN_Application_SOURCES or do I need to add a Makefile.am in each subdirectory?
For the project as depicted in the question, you can, and probably should, add them to MAIN_Application_SOURCES in the top-level Makefile.am. In that case, you probably do not need any other Makefile.am files. You should provide paths relative to the directory containing the Makefile.am, so something like:
MAIN_Application_SOURCES = \
src/main.c \
src/scheduler.c \
src/utilities/time_conversions.c
(It's not necessary to use the one-per-line format above, but I find that a lot easier to read and maintain than putting multiple filenames on one line.) In this case, you probably also want to add subdir-objects to your AUTOMAKE_OPTIONS:
AUTOMAKE_OPTIONS = foreign subdir-objects
You need more Makefile.am files only if you want more Makefiles to be generated, which ordinarily would be associated with recursive make.
Furthermore, to be useful, a Makefile.am must define at least one target to be built, and I see only one natural target in the whole project (MAIN_Application). You could introduce so-called "convenience libraries" to serve as targets for subdirectory makes, but I do not favor this approach, nor, for that matter, most uses of recursive make.
Additionally, this ...
include_HEADERS = main.h
... does not mean what you probably think it means. It says that file main.h (in, or to be generated in, the current directory) should be installed to $(includedir) by make install. It says nothing whatever about main.h's relationship to other targets. Still working on the assumption of a single top-level Makefile.am, I think what you want here is altogether different:
AM_CPPFLAGS = -I$(srcdir)/include
That will cause what appears to be an appropriate -I option to be provided to the compiler.
Supposing that you do not require support for make dist, and you do not actually want to install your header files as part of make install, you do not need to explicitly designate individual header files to Automake.
The issue is with configure.ac!
This is my new folder structure
.
├── files
│   ├── MAIN_Application
│   │   ├── autogen.sh
│   │   ├── configure.ac
│   │   ├── include
│   │   │   ├── main.h
│   │   │   ├── scheduler.h
│   │   │   └── utilities
│   │   │   └── time_conversions.h
│   │   ├── Makefile.am
│   │   ├── project.yml
│   │   ├── src
│   │   │   ├── main.c
│   │   │   ├── Makefile.am
│   │   │   ├── scheduler.c
│   │   │   └── utilities
│   │   │   └── time_conversions.c
│   │   └── test
│   │   ├── test_scheduler.c
│   │   └── test_time_conversions.c
│   └── services
│   └── mainapplication.service
└── mainapplication_0.0.bb
My top level Makefile.am contains:
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src
My Makefile.am in src contains
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = MAIN_Application
MAIN_Application_SOURCES = main.c scheduler.c time_conversions.c
Obviously these did not change from my question above. In my configure.ac I added one item to AC_CONFIG_FILES. This line changed from
AC_CONFIG_FILES([Makefile])
to
AC_CONFIG_FILES([Makefile src/Makefile])
Anytime you use a subdirectory like this you need to tell autotools about it. I solved this by searching for similar projects on GitHub and I found this.
In this project they have a top level makefile, as well as a makefile in each subdirectory containing source files. In their configure.ac they also give a path to each makefile!

Haskell Shake build: how can I set up a shared cache folder using shakeShare and/or shakeCloud?

I understand this is a new feature being worked on for GHC's Hadrian build system, so the workflow might be advanced, oddly specific, or still evolving. I read these so far:
docs/Cloud.md
Exploring Cloud Builds in Hadrian
It sounds like it should work for my use case: a domain-specific language for bioinformatics that would benefit greatly from caching comparisons between large genomes. I would be happy working from a basic minimal example or description of where to look. But I've included more details about my program too in case they make it easier...
The shortcut interpreter builds lots of artifacts with names derived from hashes of their inputs (somewhat Nix-like), and theoretically they should be portable across machines or even operating systems. A small program run might generate files + symlinks like this:
~/.shortcut
├── cache
│   ├── each
│   │   ├── 59e0192b1f
│   │   │   ├── 2633d268bf.ndb -> ../../../exprs/makeblastdb_nucl/2633d268bf_0.ndb
│   │   │   └── 2633d268bf.ndb.args -> ../../../cache/lines/3428ab5186.txt
│   │   ├── 623e07ac5b
│   │   │   ├── b9361606af.str.list -> ../../../exprs/extract_queries/b9361606af_0.str.list
│   │   │   └── b9361606af.str.list.args -> ../../../cache/lines/12ae82a598.txt
│   │   └── f477cfe47b
│   │   ├── 35e97350d8.bht -> ../../../exprs/blastn/ce1c174684_420e4f7fdf_35e97350d8_0.bht
│   │   └── 35e97350d8.bht.args -> ../../../cache/lines/9491bbe6a0.txt
│   ├── lines
│   │   ├── 0094e500eb.txt
│   │   ├── 12ae82a598.txt
│   │   ├── 246ddae0d8.txt
│   │   ├── 3428ab5186.txt
│   │   ├── 46767f8ae8.txt
│   │   ├── 5d54256d91.txt
│   │   ├── 61a97fd32d.txt
│   │   ├── 6de4b9ad67.txt
│   │   ├── 778251fd80.txt
│   │   ├── 81f7f42c42.txt
│   │   ├── 91ce94df26.txt
│   │   ├── 9491bbe6a0.txt
│   │   ├── b575c745e6.txt -> ../../cache/lines/6de4b9ad67.txt
│   │   ├── f094bac04c.txt
│   │   └── fcfb7a47a6.txt
│   ├── load
│   │   ├── 1e7afd22cf.gbk -> /home/jefdaj/shortcut/data/Mycoplasma_bovis_HB0801-P115.gbk
│   │   └── 28ce925871.gbk -> /home/jefdaj/shortcut/data/Mycoplasma_genitalium_M2321.gbk
│   ├── makeblastdb
│   │   └── 6de4b9ad67
│   │   ├── 6de4b9ad67.ndb.err
│   │   ├── 6de4b9ad67.ndb.nhr
│   │   ├── 6de4b9ad67.ndb.nin
│   │   ├── 6de4b9ad67.ndb.nsq
│   │   └── 6de4b9ad67.ndb.out
│   └── seqio
├── exprs
│   ├── any
│   │   └── e5677b1051_0.str.list.list -> ../../cache/lines/91ce94df26.txt
│   ├── blastn
│   │   ├── ce1c174684_420e4f7fdf_35e97350d8_0.bht -> ../../exprs/blastn/ce1c174684_420e4f7fdf_35e97350d8_0.bht.out
│   │   ├── ce1c174684_420e4f7fdf_35e97350d8_0.bht.out
│   │   └── ce1c174684_420e4f7fdf_35e97350d8_0.bht.out.err
│   ├── blastn_db
│   │   ├── 46e62edec1_420e4f7fdf_9ef76468c4_0.bht -> ../../exprs/blastn_db/46e62edec1_420e4f7fdf_9ef76468c4_0.bht.out
│   │   ├── 46e62edec1_420e4f7fdf_9ef76468c4_0.bht.out
│   │   └── 46e62edec1_420e4f7fdf_9ef76468c4_0.bht.out.err
│   ├── blastn_each
│   │   └── 46e62edec1_420e4f7fdf_2943ae4ea3_0.bht.list -> ../../cache/lines/12ae82a598.txt
│   ├── extract_queries
│   │   ├── 53376e198d_0.str.list -> ../../cache/lines/246ddae0d8.txt
│   │   ├── 53376e198d_0.str.list.tmp
│   │   ├── 53376e198d_0.str.list.tmp.err
│   │   ├── b9361606af_0.str.list -> ../../cache/lines/246ddae0d8.txt
│   │   ├── b9361606af_0.str.list.tmp
│   │   └── b9361606af_0.str.list.tmp.err
│   ├── extract_queries_each
│   │   └── d724d35317_0.str.list.list -> ../../cache/lines/91ce94df26.txt
│   ├── gbk_to_fna
│   │   ├── 262cf7e4e4_a355cc10e8_0.fna
│   │   └── 262cf7e4e4_cdab12f059_0.fna
│   ├── list
│   │   ├── 3bbbf950a3_0.str.list.list -> ../../cache/lines/91ce94df26.txt
│   │   ├── 65127d0127_0.fna.list -> ../../cache/lines/6de4b9ad67.txt
│   │   └── df91bd4d94_0.str.list.list.list -> ../../cache/lines/46767f8ae8.txt
│   ├── load_fna
│   ├── load_gbk
│   │   ├── 15e3d91521_0.gbk -> ../../cache/load/28ce925871.gbk
│   │   └── 74e27ec9a5_0.gbk -> ../../cache/load/1e7afd22cf.gbk
│   ├── makeblastdb_nucl
│   │   ├── 2633d268bf_0.ndb -> ../../cache/lines/81f7f42c42.txt
│   │   └── 954abc5fe7_0.ndb -> ../../cache/lines/81f7f42c42.txt
│   ├── makeblastdb_nucl_each
│   │   └── 209fe6406d_0.ndb.list -> ../../cache/lines/5d54256d91.txt
│   ├── num
│   │   └── a53b190835_0.num -> ../../cache/lines/778251fd80.txt
│   ├── singletons
│   │   └── 954abc5fe7_0.fna.list.list -> ../../cache/lines/0094e500eb.txt
│   └── str
│   ├── 90811d06ee_0.str -> ../../cache/lines/f094bac04c.txt
│   ├── b4da62b027_0.str -> ../../cache/lines/fcfb7a47a6.txt
│   └── b81c880be5_0.str -> ../../cache/lines/61a97fd32d.txt
├── profile.html
└── vars
├── mapped.str.list.list -> ../exprs/extract_queries_each/d724d35317_0.str.list.list
├── mbov.fna -> ../exprs/gbk_to_fna/262cf7e4e4_a355cc10e8_0.fna
├── mgen.fna -> ../exprs/gbk_to_fna/262cf7e4e4_cdab12f059_0.fna
├── result -> ../exprs/any/e5677b1051_0.str.list.list
└── single.str.list -> ../exprs/extract_queries/53376e198d_0.str.list
27 directories, 64 files
I tried adding shakeShare = Just "sharedir" to my Shake options. When I run the build, delete all artifacts, and re-run, it fails to find a cached file:
error! Error when running Shake build system:
at want, called at ./ShortCut/Core/Eval.hs:253:7 in main:ShortCut.Core.Eval
* Depends on: eval
at need, called at ./ShortCut/Core/Eval.hs:256:25 in main:ShortCut.Core.Eval
* Depends on: /root/.shortcut/vars/result
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/all/b2ba759dce_0.str.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/any/0a89231af6_0.str.list.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/list/df91bd4d94_0.str.list.list.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/vars/mapped.str.list.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/extract_queries_each/730901fdda_0.str.list.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/tblastn_each/46e62edec1_183f436b85_a5a22079c6_0.bht.list
at need, called at ./ShortCut/Core/Actions.hs:110:3 in main:ShortCut.Core.Actions
* Depends on: /root/.shortcut/exprs/num/a53b190835_0.num
* Raised the exception:
/home/jefdaj/shortcut/sharedir/.shake.cache/2faae061b9976bed/0x134125AC: getPermissions:getFileStatus: does not exist (No such file or directory)
That was expected, but now how do I go about fixing it? The hashes should be stable because all symlinks are relative to the top level tmpdir (~/.shortcut here). And Shake should know about each of them since I make sure to call trackWrite.
Do I need to explicitly add all files to a cache using newCache, newCacheIO, and/or an oracle as they're built, or am I missing something simpler?
Ideally I would have a shared directory to cache everything done on the demo server, and also give users the option to connect their own instances to it like a Nix binary cache.
I misunderstood what Shake caches are for: I assumed they cache build artifacts indexed by all their inputs, but actually they just cache reading + processing of files used to decide things while producing those artifacts. Like in this example from the docs:
digits <- newCache $ \file -> do
src <- readFile' file
return $ length $ filter isDigit src
"*.digits" %> \x -> do
v1 <- digits (dropExtension x)
v2 <- digits (dropExtension x)
writeFile' x $ show (v1,v2)
As it says, "This function is useful when creating files that store intermediate values, to avoid the overhead of repeatedly reading from disk, particularly if the file requires expensive parsing." I think the cache here is equivalent to writing an intermediate .digits file and needing it twice.
I implemented what I was looking for separately by writing a need' function that checks if a file is in the cache (local or remote), fetches it if possible, and then calls Development.Shake.need. Depending on the build system, it might also be possible to do this kind of "caching" with something like rsync.
The Shake cache still looks very useful for the part of my code that needs to read a list of all sequence IDs into memory once per program run and refer to them later from various rules.
I think there's a confusion here that newCache and newCacheIO are involved with the Cloud Shake feature. They aren't - in fact, newCache happens to be one of the things that has no impact on the cloud cache (coincidentally, rather than because of the Cache in the name). I see no reason your use case shouldn't work with Cloud Shake.
The exception /home/jefdaj/shortcut/sharedir/.shake.cache/2faae061b9976bed/0x134125AC: getPermissions:getFileStatus: does not exist (No such file or directory) seems to imply that Shake has recorded that the above file is in the cache, and can be used to satisfy the file. So the question is where did the file go? Is it possible when you cleaned the files that they deleted the files from the cache too? Shake can be run with both --share-copy and --share-symlink - I'd recommend the former to ensure there is less action-at-a-distance, which might also explain what is deleting the files. I'd also recommend using Shake HEAD, as there are some fixes that haven't yet been released.
If that still doesn't work, perhaps raise a ticket on the Shake GitHub?

CMake: Creating a shared android library with the correct path to its shared library dependency

I'm trying to create a native (no Java code) shared Android library that I can then DllImport from C# in the Unity game engine. Unfortunately, my code depends on a complex 3rd party shared library (libtensorflow.so) and I can't figure out how to link against it such that it can resolve the symbols it needs after being deployed.
When Unity creates an apk, it bundles all .so files into the same directory (see Unity bundled directory structure), and loading libmy_library.so fails because it can't find ../../../../src/main/jniLibs/armeabi-v7a/libtensorflow.so. This path is embedded in the shared library (as verified with ndk-depends) and I might be able to change that using some patcher, but I think there's a simple CMakeLists.txt modification I'm missing. Sadly, I don't know enough about how CMake, Android Studio, or shared libraries work in order to figure it out.
Every change I've tried to set_target_properties results in ninja: error: 'libtensorflow.so', needed by '../../../../build/intermediates/cmake/debug/obj/x86/libmy_library.so', missing and no known rule to make it.
Omitting libtensorflow from the target_link_libraries results in app/src/main/cpp/native-lib.cpp:8: error: undefined reference to [...].
How can I tell CMake where the .so I'm linking against will be while letting it find it where it is now?
$ndk-depends --print-direct libmy_library.so
liblog.so
../../../../src/main/jniLibs/armeabi-v7a/libtensorflow.so
libm.so
libstdc++.so
libdl.so
libc.so
Unity bundled directory structure:
├── ObjectIdentifier
│   ├── build.gradle
│   ├── libs
│   │   └── unity-classes.jar
│   ├── local.properties
│   ├── proguard-unity.txt
│   └── src
│   └── main
│   ├── AndroidManifest.xml
│   ├── assets
│   ├── java
│   ├── jniLibs
│   │   ├── armeabi-v7a
│   │   │   ├── libmain.so
│   │   │   ├── libmono.so
│   │   │   ├── libmy_library.so
│   │   │   ├── libtensorflow.so
│   │   │   └── libunity.so
│   │   └── x86
│   │   ├── libmain.so
│   │   ├── libmono.so
│   │   ├── libmy_library.so
│   │   ├── libtensorflow.so
│   │   └── libunity.so
│   └── res
My Android Studio Project Hierarchy:
├── MyLibrary.iml
├── app
│   ├── CMakeLists.txt
│   ├── app.iml
│   ├── build
│   ├── build.gradle
│   ├── libs
│   ├── proguard-rules.pro
│   └── src
│   └── main
│   ├── AndroidManifest.xml
│   ├── cpp
│   │   ├── c_api.h
│   │   └── native-lib.cpp
│   └── jniLibs
│   ├── armeabi-v7a
│   │   └── libtensorflow.so
│   └── x86
│   └── libtensorflow.so
├── build.gradle
├── gradle
│   └── wrapper
│   ├── gradle-wrapper.jar
│   └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
CMakeLists.txt:
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
my_library
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
src/main/cpp/c_api.h
src/main/cpp/native-lib.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
set(ANDROID_SO_OUTDIR ${CMAKE_HOME_DIRECTORY}/../../../MyUnityProject/Assets/MyLibrary/Plugins/Android/libs)
add_library(tensorflow-lib SHARED IMPORTED)
set_target_properties(tensorflow-lib PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libtensorflow.so)
target_link_libraries(my_library
${log-lib}
tensorflow-lib
)
#
# Copy the built library into the appropriate folder in MyUnityProject
#
add_custom_command(TARGET my_library POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libmy_library.so
${ANDROID_SO_OUTDIR}/${ANDROID_ABI}/libmy_library.so)
app/build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags "-v -Wall"
}
}
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
// let gradle pack the shared library into apk
jniLibs.srcDirs = ['../src/main/jniLibs']
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

any specific example of making a dictionary using logios

I followed this tutorial trying to build a dictionary, but I think the logios package is generally used for gram and classes file given as input. If I understood it correctly, the dictionary should be built by feeding either a sample text file or a vocabulary file, there shouldn't be any gram file involved. So my questions are
A) Is my understanding about the input correct?
B) Based on above assumption, I guess the correct way of using the package is not building them all, but rather making use of a component inside Tools directory named MakeDict. But I fell short of any solid example of how to use this tool. So I tried by making modification to test_MakeDict.sh file, but it failed with no further information on which component fails. So what shall I do next? Can anyone give any solid command line examples on using this tool, and shall I build the whole package first before I can use any individual component?
The directory layout in MakeDict is as
.
├── AUTHORS
├── bin
│   ├── x86-linux
│   │   └── pronounce
│   └── x86-nt
│   ├── libgnurx-0.dll
│   └── pronounce.exe
├── dict
│   ├── command.dic
│   ├── command.txt
│   ├── command.vocab
│   ├── hand.dic
│   └── pronunciation.log
├── lextool.pl
├── lib
│   ├── lexdata
│   │   ├── lexicon.data
│   │   ├── lexicon.key
│   │   ├── ltosru.bin
│   │   ├── nslex.900
│   │   └── nslex.901
│   └── Pronounce.pm
├── logios.log
├── make_pronunciation.pl
├── README
├── test
│   ├── example
│   ├── example.dic.test
│   ├── hand.dict
│   └── pronunciation.log.test
└── test_MakeDict.sh
You have to use the pronounce executable. Depending on your OS you will have to use the linux or nt version.
You can use it as follows:
(from the MakeDict root directory)
./bin/x86-linux/pronounce -d [name of the dictionary you want to use from the dict folder] -i [words file] -o [destination dictionary]
The words file must be a file contanining the words you want to include in the dictionary, one per line.
The dictionary I used was cmudict_SPHINX_40. I don't know which one you should use.

How to run a groovy script from gradle that depends on another script

I'm playing around with the samples directory that comes with Gradle and trying to create a simple task that runs a groovy script which depends on another script.
The structure of the project looks like this:
.
├── build.gradle
└── src
├── main
│   ├── groovy
│   │   └── org
│   │   └── gradle
│   │   └── Person.groovy
│   └── resources
│   ├── resource.txt
│   └── script.groovy
└── test
├── groovy
│   └── org
│   └── gradle
│   └── PersonTest.groovy
└── resources
├── testResource.txt
└── testScript.groovy
I've added the following task in build.gradle
task runScript << {
new GroovyShell().run(file('src/main/resources/script.groovy'))
}
The error I'm getting is:
FAILURE: Build failed with an exception.
* Where:
Build file '/gradle/gradle-1.0/samples/groovy/quickstart/build.gradle' line: 13
* What went wrong:
Execution failed for task ':runScript'.
Cause: No such property: person for class: script
contents of script.groovy are:
person.name = person.name[0].toUpperCase() + person.name[1..-1]
contents of Person.groovy are:
package org.gradle
class Person {
String name
def Person() {
getClass().getResourceAsStream('/resource.txt').withStream {InputStream str ->
name = str.text.trim()
}
getClass().getResourceAsStream('/script.groovy').withStream {InputStream str ->
def shell = new GroovyShell()
shell.person = this
shell.evaluate(str.text)
}
}
}
Question
How can I add a task that would simply run script.groovy which makes use of another groovy class (Person)
You can use buildSrc folder where you can hold Groovy / Java sources that will be compiled before executing any task in your initial build script and added to the class path. That will make all those classes available to be used in the tasks. You can read more about it in: http://gradle.org/docs/current/userguide/organizing_build_logic.html
Regarding your script.grooovy I would just put the code into the task itself rather than calling it through GroovyShell. If you want to externalize the task you can use apply command.
apply from: 'script.gradle'
You can take a look at this question: How can I import one Gradle script into another?

Resources