In the regular Javadoc generation process, we can simply exclude a class or package by adding the below lines.
exclude '**/SampleClass.java'
exclude '**/com/example/java**'
Question: How to exclude/suppress a single Kotlin/java class with the Dokka tool ??
Below is the code to exclude a package.
Is there any option to exclude a particular class?
perPackageOption {
matchingRegex.set("com.example.xxx.xxx.package.*")
suppress.set(true)
}
Dokka tool ref: https://kotlinlang.org/docs/kotlin-doc.html
Tool configurations: https://kotlin.github.io/dokka/1.5.0/user_guide/gradle/usage/#configuration-options
Related
We have a maven project that uses iText5. We would like to migrate to iText7. There are many parts that use the old library. Are there any contraindications in temporarily keeping both libraries as a reference in the pom and using the old version in some parts and the new in others? We will gradually replace the old one. We will permanently delete the old one after a long process of refactoring and testing.
when using itext5 and itext7 gives the same file errors.
need to exclude that file using the packaging option.
The below code will fix the compile-time build failed
android {
packagingOptions {
exclude 'com/itextpdf/io/font/cmap/HYGoThic-Medium.properties'
}
}
The below code will fix the Run-time build and make the application install
android {
packagingOptions {
exclude 'com/itextpdf/io/font/cmap/cjk_registry.properties'
exclude 'com/itextpdf/io/font/cmap/HeiseiKakuGo-W5.properties'
exclude 'com/itextpdf/io/font/cmap/HeiseiMin-W3.properties'
exclude 'com/itextpdf/io/font/cmap/HYGoThic-Medium.properties'
exclude 'com/itextpdf/io/font/cmap/HYSMyeongJo-Medium.properties'
exclude 'com/itextpdf/io/font/cmap/HYSMyeongJoStd-Medium.properties'
exclude 'com/itextpdf/io/font/cmap/KozMinPro-Regular.properties'
exclude 'com/itextpdf/io/font/cmap/MHei-Medium.properties'
exclude 'com/itextpdf/io/font/cmap/MSung-Light.properties'
exclude 'com/itextpdf/io/font/cmap/MSungStd-Light.properties'
exclude 'com/itextpdf/io/font/cmap/STSong-Light.properties'
exclude 'com/itextpdf/io/font/cmap/STSongStd-Light.properties'
exclude 'com/itextpdf/io/font/cmap_info.txt'
}
}
I have a jar that I am including in my Android project using the following syntax
implementation files('lib/fm.liveswitch.jar')
fm.liveswitch has a dependency of org.bouncycastle that I am already including as a dependency of my project. How do I exclude bouncycastle from being included as part of the jar?
I have already tried each of the following:
implementation (files('lib/fm.liveswitch.jar')) {
exclude group: 'org.bouncycastle'
}
implementation (files('lib/fm.liveswitch.jar')) {
exclude module: 'org.bouncycastle'
}
implementation (files('lib/fm.liveswitch.jar'), {
exclude group: 'org.bouncycastle'
})
implementation files('lib/fm.liveswitch.jar') {
exclude group: 'org.bouncycastle'
}
But each time I get an error similar to the below:
Could not find method exclude() for arguments [{group=org.bouncycastle}] on object of type org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency
When you add file based dependencies, they have no dependency metadata and thus no transitive dependency information.
Given this, there is no point in trying to add an exclude.
Adding implementation files('lib/fm.liveswitch.jar') will only add fm.liveswitch.jar on the classpath, nothing else.
Now if that JAR contains some bouncycastle classes inside, it is a different story. Gradle has no direct way of letting you control the visibility of the contents of a JAR.
You would then have two options:
Since it is a local JAR, you can yourself remove the offending classes from it.
You could attempt to leverage artifact transforms
Is it somehow possible to exclude test classes from java-to-ObjcC conversion with j2objc-gradle plugin?
The J2ObjC Gradle Plugin can exclude files from both translation and tests. It uses Ant style exclude / include pattern matching on filenames. This is is described in the Gradle documentation with examples and the PatternFilterable class.
As a simple example:
j2objcConfig {
...
testPattern {
// Only run Java unit tests that end with "Test.java"
include '**/*Test.java'
// Exclude a single test without needing to specify the full path
exclude '**/LogTest.java'
// Exclude all tests within "ignoreDirectory"
exclude 'ignoreDirectory/**'
}
...
}
Given a gradle project A having a dependency on project B (no common parent)
compile project('B'){
exclude group: 'org.slf4j'
}
how do we exclude transitive dependency group from a project we depend upon? (this piece of script will fail as there is no exclude for compile projet(..))
and more general question : is there an elegant way to exclude a particular group from all dependancies except if its a first level dependency?
for example we may have a bunch of libraries, and each may declare its logging environment, but by excluding all known groups of slf4j, its implementations and declaring specific version, we would ensure we don't have any version conflicts and would control version on module level.
Here is an example from the Gradle documentation of how to exclude a transitive dependency (I guess that is what you meant by "except if its a first level dependency") on project level:
configurations {
compile.exclude module: 'commons'
all*.exclude group: 'org.gradle.test.excludes', module: 'reports'
}
See 52.4.7. Excluding transitive dependencies here
You can either specify the dependency directly with the desired version or use a forced version resolution strategy
To add a simple dependency on test source sets from an another subproject I can do:
testCompile project(':subFoo1').sourceSets.test.output
This solution works, but in many cases it is not intended to add the whole source set as a dependency. For example I would like to use only test data builders and in that case files like test-logback.xml (and regular tests) pollute my test classpath in the master module.
I tried the idea with test JAR (which can have filtered content, but is problematic as a dependency) and some combination with eachFileRecurse, but with no luck.
My question. How can I add only a subset of given source set(s) (e.g. only classes with builders matching **/*Builder.* pattern) as a testCompile dependency in another subproject?
You'll want something along the lines of:
upstream/build.gradle:
apply plugin: "java"
task testJar(type: Jar) {
classifier = "tests"
from sourceSets.test.output
exclude "**/*Test.class"
}
artifacts {
testRuntime testJar
}
downstream/build.gradle:
apply plugin: "java"
dependencies {
testCompile project(path: ":upstream", configuration: "testRuntime")
}
Instead of using testRuntime, you could also declare (e.g. configurations { testFixture }) and use a custom configuration, which would give you more control over which external dependencies are passed on to downstream projects. Yet another option would be to declare a separate source set for the part of the test code that is to be passed on. (This would also give you separate compile and runtime configurations to work with.)
PS: Reaching out into another project's object model (e.g. project(':subFoo1').sourceSets.test.output) is problematic, and should be avoided when possible.