Skip to content

Instantly share code, notes, and snippets.

Žan Skamljič zskamljic

  • EqualEyes Solutions Ltd.
Block or report user

Report or block zskamljic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MockitoTest.java
import org.junit.Before;
import org.junit.Test;
import static junit.framework.TestCase.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class MockitoTest {
interface StringProvider {
View setup.java
@Before
public void setUp() {
}
@After
public void tearDown() {
}
View simpletest.java
@Test
public void testSometing() {
testedObject.doSomething();
}
View add method.java
void addLogMethod(CtClass ctClass) {
String body = "System.out.println(\"Added later\");";
CtConstructor[] constructors = ctClass.getConstructors();
if (constructors == null) return;
for (CtConstructor constructor : constructors) {
addCodeIfNeeded(constructor, body);
}
}
void addCode(CtConstructor constructor, String body) {
View get classes.java
Set<String> getClassNames(Collection<TransformInput> inputs) {
Set<String> classNames = new HashSet<>();
for (TransformInput input : inputs) {
classNames.addAll(getDirectoryInputs(input.getDirectoryInputs()));
classNames.addAll(getJarInputs(input.getJarInputs()));
}
return classNames;
}
View CustomTransform.java
public class CustomTransform extends Transform {
@Override
public String getName() {
return "CustomProc";
}
@Override
public Set<QualifiedContent.ContentType> getInputTypes() {
return ImmutableSet.of(QualifiedContent.DefaultContentType.CLASSES);
}
View registering transformer.java
void registerTransformer() {
Object android = project.findProperty("android");
if (android instanceof BaseAppModuleExtension) {
System.err.println("Adding transform");
((BaseAppModuleExtension) android).registerTransform(new CustomTransform());
}
}
View gist:56292d9812fadd0bc32690cb22bfde24
pluginBundle {
website = "https://google.com"
vcsUrl = "https://gitlab.com/zskamljic"
description = "demo plugin"
tags = ["demo", "plugin"]
plugins {
demoPlugin {
id = 'equaleyes.demo'
displayName = 'Demo Plugin'
View addDependencies.java
void addDependencies() {
project.getRepositories().add(project.getRepositories().jcenter());
addAnnotationProcessor();
DependencyHandler dependencies = project.getDependencies();
dependencies.add("implementation", "com.lablizards.depend:depend:1.2.0");
dependencies.add("compileOnly", "com.lablizards.depend:depend-annotations:1.2.0");
dependencies.add("annotationProcessor", "com.lablizards.depend:depend-compiler:1.2.0");
}
View DemoPlugin.java
package com.equaleyes.demoplugin;
import org.gradle.api.*;
@NonNullApi
public class DemoPlugin implements Plugin<Project> {
private static final String TRANSFORM_CLASS = "com.android.build.api.transform.Transform";
private static final String ERROR_PLUGIN_REQUIRED = "'com.android.application' or 'com.android.library' plugin required";
private static final String ERROR_PLUGIN_OUTDATED = "Gradle plugin 1.5.0 or later is required.";
You can’t perform that action at this time.