Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dependency:unpack
- dependency:unpack
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>aspectj-maven-plugin</artifactId>
- <version>1.4</version>
- <configuration>
- <showWeaveInfo>true</showWeaveInfo>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- <executions>
- <execution>
- <id>test-compile</id>
- <configuration>
- <weaveMainSourceFolder>true</weaveMainSourceFolder>
- </configuration>
- <goals>
- <goal>test-compile</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>${aspectj.version}</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjtools</artifactId>
- <version>${aspectj.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- <project>
- ...
- <build>
- <plugins>
- ...
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>aspectj-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-compile</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- ...
- </plugins>
- <build>
- ...
- </project>
- @Aspect
- public class TweakSystemAspects {
- private static long timeOffsetMillis = 0;
- public static void advanceTime(int amount, TimeUnit unit) {
- timeOffsetMillis += unit.toMillis(amount);
- }
- @Around("call (long System.currentTimeMillis())")
- public long aroundSystemTime(ProceedingJoinPoint joinPoint) throws Throwable {
- return ((Long) joinPoint.proceed()) + timeOffsetMillis;
- }
- }
- <aspectj>
- <aspects>
- <aspect name="com.mypackage.TweakSystemAspects"/>
- </aspects>
- <weaver options="-nowarn -Xlint:ignore"/>
- <!-- During testing this was useful, but I didn't want all that output normally. -->
- <!--<weaver options="-verbose -showWeaveInfo"/>-->
- </aspectj>
- <project ...>
- ...
- <properties>
- ...
- <version.aspectj>1.8.10</version.aspectj>
- <properties>
- <dependencies>
- ...
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>${version.aspectj}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- ...
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- For Load Time Weaving of our AspectJ helper code -->
- <argLine>-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${version.aspectj}/aspectjweaver-${version.aspectj}.jar</argLine>
- ...
- </configuration>
- </plugin>
- </plugins>
- </build>
- ...
- </project>
Add Comment
Please, Sign In to add comment