I'm using Android studio 1.4.1 and I'm trying to setup findbugs but even setting the exclude xml with R and Manifest findbugs still analise them.
I want to:
Setup findbugs with android to avoid R and all of those generated things, like ViewBinder and Lambda.
Gradle file:
apply plugin: 'findbugs'
apply plugin: 'pmd'
findbugs {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
reportLevel = "low"
effort = "max"
excludeFilter = file("../setup/findbugs-exclude.xml")
}
pmd {
ignoreFailures = true
reportsDir = file("$project.buildDir/outputs/")
}
task findbugs(type: FindBugs, dependsOn: assembleDebug) {
description 'Run findbugs'
group 'verification'
classes = fileTree("build/intermediates/classes/debug/")
source = fileTree('src/main/java')
classpath = files()
reports {
xml.enabled = false
html.enabled = true
}
}
task pmd(type: Pmd, dependsOn: assembleDebug) {
description 'Run pmd'
group 'verification'
ruleSets = ["java-basic", "java-braces", "java-strings", "java-design", "java-unusedcode"]
source = fileTree('src/main/java')
reports {
xml.enabled = false
html.enabled = true
}
}
check.doLast {
project.tasks.getByName("findbugs").execute()
project.tasks.getByName("pmd").execute()
}
findbugs-exclude.xml
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="~.*\.R\$.*" />
</Match>
<Match>
<Class name="~.*\.Manifest\$.*" />
</Match>
</FindBugsFilter>
Response:
Code analyzed:
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$anim.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$attr.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$bool.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$color.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$dimen.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$drawable.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$id.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$integer.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$layout.class
/Users/me/Documents/test-android/app/build/intermediates/classes/debug/android/support/design/R$string.class
UPM Private method com.test.android.player.service.PlayerServicePresenter$$Lambda$1.get$Lambda(PlayerServicePresenter) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda$1.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpActivity$$Lambda$4.get$Lambda(SignUpActivity) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda$1.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.sign_up.SignUpPresenter$$Lambda$2.get$Lambda(SignUpPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialActivity$$Lambda$1.get$Lambda(TutorialActivity) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$1.get$Lambda(TutorialPresenter, String) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$2.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.tutorial.TutorialPresenter$$Lambda$3.get$Lambda(TutorialPresenter) is never called
UPM Private method com.test.android.utils.base.BaseView$$Lambda$1.get$Lambda(BaseView) is never called
Maybe this would help. Just add to findbugs-exclude.xml this code:
<Match>
<Bug code="UPM" />
<Class name="~.*\$\$Lambda\$.*"/>
</Match>
Related
I'm trying to compile generated Kotlin source code in a custom location to a custom location so that I can build a jar file with those class file only.
I had no issues setting it up for Java. Unfortunately, I'm having problems with Kotlin.
So here is the Kotlin version of what worked for me in Java:
public class MyCustomPlugin implements Plugin<Project> {
private static final String GENERATED_STUB_CLASSES_DIRECTORY = "generated-stub-classes";
private static final String GENERATED_STUB_SOURCES_DIRECTORY = "generated-stub-sources";
public void apply(Project project) {
project.getPluginManager().apply(KotlinPluginWrapper.class);
createCompileStubsTask(project);
}
private void createCompileStubsTask(final Project project) {
KotlinCompile compileKotlin = (KotlinCompile) project.getRootProject().getTasksByName("compileKotlin", true).iterator().next();
TaskProvider<KotlinCompile> compileKotlinStubs = project.getTasks().register("compileStubs", KotlinCompile.class,
compileStubs -> {
File stubsClassesDir = new File(project.getBuildDir() + "/" + GENERATED_STUB_CLASSES_DIRECTORY);
stubsClassesDir.mkdirs();
compileStubs.setClasspath(compileKotlin.getClasspath());
compileStubs.source(project.getLayout().getBuildDirectory().dir(GENERATED_STUB_SOURCES_DIRECTORY));
compileStubs.getDestinationDirectory().set(stubsClassesDir);
});
compileKotlin.finalizedBy(compileKotlinStubs);
}
}
This fails with:
Unable to determine constructor argument #1: missing parameter of type KotlinJvmOptions, or no service of type KotlinJvmOptions.
I tried to do it in the build.gradle file, like this:
task compileStubs(type: org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
File stubsClassesDir = new File(project.getBuildDir().name + "/generated-stub-classes")
stubsClassesDir.mkdirs()
compileStubs.setClasspath(compileKotlin.getClasspath())
compileStubs.source(project.getLayout().getBuildDirectory().dir("generated-stub-sources"))
compileStubs.getDestinationDirectory().set(stubsClassesDir)
}
compileKotlin.finalizedBy(compileKotlinStubs)
But the result is exactly the same.
Please help...
I tried to generate two swagger yaml files in one build script
Here is my code
plugins {
kotlin("jvm")
id("org.openapi.generator")
}
sourceSets {
main {
java.srcDir("$buildDir/generate-resources/main/src/main/kotlin")
}
}
dependencies {
val jacksonVersion: String by project
implementation(kotlin("stdlib"))
testImplementation(kotlin("test-junit"))
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
}
val dir = File("$rootDir/transport/spec/".toString())
val swaggerList: ArrayList<String> = ArrayList()
dir.walkTopDown().forEach {
val endsWith = it.name.endsWith(".yaml")
if (endsWith) {
swaggerList.add(it.name)
}
}
swaggerList.forEach {swaggerItem->
println(swaggerItem)
val apiName = swaggerItem.replace(".yaml", "")
tasks.create(
"openApiGenerate" + apiName.capitalize(),
org.openapitools.generator.gradle.plugin.tasks.GenerateTask::class)
{
val openapiGroup = "${rootProject.group}.openapi"
generatorName.set("kotlin")
packageName.set(openapiGroup)
apiPackage.set("$openapiGroup.api")
modelPackage.set("$openapiGroup.models")
invokerPackage.set("$openapiGroup.invoker")
inputSpec.set("$rootDir/transport/spec/$swaggerItem")
println("setup input spec")
globalProperties.apply {
put("models", "")
put("modelDocs", "false")
}
configOptions.set(
mapOf(
"dateLibrary" to "string",
"enumPropertyNaming" to "UPPERCASE",
"serializationLibrary" to "jackson",
"collectionType" to "list"
)
)
}
}
tasks {
compileKotlin {
dependsOn(openApiGenerate)
}
}
I launched this code via gradle build, but nothing works
I got this error
In plugin 'org.openapi.generator' type 'org.openapitools.generator.gradle.plugin.tasks.GenerateTask' property 'inputSpec' doesn't have a configured value.
Reason: This property isn't marked as optional and no value has been configured.
Possible solutions:
Assign a value to 'inputSpec'.
Mark property 'inputSpec' as optional.
I tried to assign this property in different ways it was unsuccessful
how I can fix it ?
In your build.gradle you are creating multiple tasks for each item in swaggerList. Each task is named: "openApiGenerate" + apiName.capitalize(). So when you call your build like this:
gradle openapiGenerate
it tries to use a default task configured with this name and not any of the ones you are creating.
Can you try to run it:
gradle openapiGenerateYOUR_API_NAME
and check what's the result?
In my case, the same error message was caused by having a compileJava.dependsOn tasks.openApiGenerate in the wrong build.gradle file.
Apparently there's no support for metarunners generation in TeamCity Kotlin DSL. The files remain in plain XML.
How do I replace it using available DSL features? Say I'd like to do this:
steps {
step {
type = "mymetarunner" // compound meta-runner step
}
}
How do I define mymetarunner using Kotlin?
At the moment (TeamCity 2017.2), there is no way to define metarunners using Kotlin DSL.
Update
If having a real metarunner is not required, the solution is a small exercise in Kotlin DSL
Define a container class for settings you need for "metarunner"
class MyConfigClass {
var name = "Default Name"
var goals = "build"
var tasks = "build test"
var someUnusedProperty = 0
}
Define an extension function for steps block
fun BuildSteps.myMetaRunner(config: MyConfigClass.() -> Unit) {
val actualConfig = MyConfigClass() // new config instance
actualConfig.config() // apply closure to fill the config
// use the config to create actual steps
maven {
name = actualConfig.name
goals = actualConfig.goals
}
ant {
name = actualConfig.tasks
}
}
Use the extension function wherever you need
object A_Build : BuildType({
uuid = ...
steps {
myMetaRunner {
name = "This name will be used by maven step"
goals = "build whatever_goal"
tasks = "more ant tasks"
}
}
})
Bingo!
I am trying to create a Lucene index in Sitecore 8.x of items that are visible to unauthenticated users (extranet\Anonymous). In order to do this I am trying to use the indexing.filterIndex.inbound pipeline.
I have tried writing a custom pipeline that returns false if the item cannot be read as extranet\Anonymous:
public class ApplyInboundIndexAccessFilter : InboundIndexFilterProcessor
{
public override void Process(InboundIndexFilterArgs args)
{
var item = args.IndexableToIndex as SitecoreIndexableItem;
var anonymousUser = Sitecore.Security.Accounts.User.FromName("extranet\\anonymous", false);
if (!item.Item.Security.CanRead(anonymousUser))
{
args.IsExcluded = true;
}
}
}
but at no time does this pipeline get invoked.
I have added my config (tried it with the default, before, after, with the default removed)
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<indexing.filterIndex.inbound>
<processor type="MyApplication.Site.Features.ContentSearch.IndexFilters.ApplyInboundIndexAccessFilter, MyApplication.Site">
<includedIndexNames hint="list">
<indexName>siteSearchIndex_web</indexName>
</includedIndexNames>
<excludedIndexNames hint="list">
<indexName>siteSearchIndex_master</indexName>
</excludedIndexNames>
</processor>
</indexing.filterIndex.inbound>
</pipelines>
</sitecore>
</configuration>
Am I right in assuming that this should be called on indexing, if not, when?
Any suggestions would be gratefully received.
I am adding my custom gradle task in my libraries build.gradle with Doclava implementation as:
android.libraryVariants.all { variant ->
task("generateNew${variant.name.capitalize()}Javadoc", type: Javadoc) {
title = ""
destinationDir = new File("${project.getProjectDir()}/doc/compiled/", variant.baseName)
description "Generates Javadoc for $variant.name."
source = variant.javaCompile.source
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) + project.files(android.getBootClasspath().join(File.pathSeparator))
options {
memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PRIVATE
links "http://docs.oracle.com/javase/8/docs/api/"
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
doclet = "com.google.doclava.Doclava"
List<File> pathList = new ArrayList<File>();
pathList.add(file('./libs/doclava-1.0.6.jar'))
docletpath = pathList
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}
and when I run the task gradle give me the error javadoc: error - invalid flag: -link. But the task can be run when I remove the links & linksOffline option. Another problem is the provided PRIVATE member option is not working, the generated document shows only public members.
Is there any way around to fix it so that with the Doclava doclet I can get the reference links to the Android and Java references?