Skip to content

Commit

Permalink
initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrus committed Mar 31, 2018
0 parents commit 6bc9e70
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.iml
.idea
target
dependency-reduced-pom.xml
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Idea Setup

Go to "Preferences > Annoration Processors", and check "Enable Annotation
Processing".
99 changes: 99 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.objectstyle</groupId>
<artifactId>dagger-sandbox</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>jar</packaging>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

<dagger.version>2.15</dagger.version>

<main.class>org.objectstyle.dagger.Main</main.class>
</properties>


<dependencies>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>${dagger.version}</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>${dagger.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>


<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>

<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${main.class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
9 changes: 9 additions & 0 deletions src/main/java/org/objectstyle/dagger/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.objectstyle.dagger;

public class Main {

public static void main(String[] args) {
Root r = DaggerRoot.create();
System.out.println(r.service().doIt());
}
}
26 changes: 26 additions & 0 deletions src/main/java/org/objectstyle/dagger/MainModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.objectstyle.dagger;

import dagger.Module;
import dagger.Provides;
import org.objectstyle.dagger.service.Service;
import org.objectstyle.dagger.service.ServiceImpl;
import org.objectstyle.dagger.service.SubService;
import org.objectstyle.dagger.service.SubServiceImpl;

import javax.inject.Singleton;

@Module
public class MainModule {

@Provides
@Singleton
Service provideService(SubService subService) {
return new ServiceImpl(subService);
}

@Provides
@Singleton
SubService provideSubService() {
return new SubServiceImpl();
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/objectstyle/dagger/Root.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.objectstyle.dagger;

import dagger.Component;
import org.objectstyle.dagger.service.Service;

import javax.inject.Singleton;

@Singleton
@Component(modules = MainModule.class)
public interface Root {

Service service();
}
7 changes: 7 additions & 0 deletions src/main/java/org/objectstyle/dagger/service/Service.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.objectstyle.dagger.service;


public interface Service {

String doIt();
}
14 changes: 14 additions & 0 deletions src/main/java/org/objectstyle/dagger/service/ServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.objectstyle.dagger.service;

public class ServiceImpl implements Service {

private SubService subService;

public ServiceImpl(SubService subService) {
this.subService = subService;
}

public String doIt() {
return "ServiceImpl_" + subService.doIt();
}
}
5 changes: 5 additions & 0 deletions src/main/java/org/objectstyle/dagger/service/SubService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.objectstyle.dagger.service;

public interface SubService {
String doIt();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.objectstyle.dagger.service;

public class SubServiceImpl implements SubService {

public String doIt() {
return "SubServiceImpl";
}
}

0 comments on commit 6bc9e70

Please sign in to comment.