Guest User

Untitled

a guest
Dec 11th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. dependency:unpack
  2.  
  3. dependency:unpack
  4.  
  5. <plugin>
  6. <groupId>org.codehaus.mojo</groupId>
  7. <artifactId>aspectj-maven-plugin</artifactId>
  8. <version>1.4</version>
  9. <configuration>
  10. <showWeaveInfo>true</showWeaveInfo>
  11. <source>1.7</source>
  12. <target>1.7</target>
  13. </configuration>
  14. <executions>
  15. <execution>
  16. <id>test-compile</id>
  17. <configuration>
  18. <weaveMainSourceFolder>true</weaveMainSourceFolder>
  19. </configuration>
  20. <goals>
  21. <goal>test-compile</goal>
  22. </goals>
  23. </execution>
  24. </executions>
  25. <dependencies>
  26. <dependency>
  27. <groupId>org.aspectj</groupId>
  28. <artifactId>aspectjrt</artifactId>
  29. <version>${aspectj.version}</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>org.aspectj</groupId>
  33. <artifactId>aspectjtools</artifactId>
  34. <version>${aspectj.version}</version>
  35. </dependency>
  36. </dependencies>
  37. </plugin>
  38.  
  39. <project>
  40. ...
  41. <build>
  42. <plugins>
  43. ...
  44. <plugin>
  45. <groupId>org.codehaus.mojo</groupId>
  46. <artifactId>aspectj-maven-plugin</artifactId>
  47. <executions>
  48. <execution>
  49. <goals>
  50. <goal>test-compile</goal>
  51. </goals>
  52. </execution>
  53. </executions>
  54. </plugin>
  55. ...
  56. </plugins>
  57. <build>
  58. ...
  59. </project>
  60.  
  61. @Aspect
  62. public class TweakSystemAspects {
  63. private static long timeOffsetMillis = 0;
  64.  
  65. public static void advanceTime(int amount, TimeUnit unit) {
  66. timeOffsetMillis += unit.toMillis(amount);
  67. }
  68.  
  69. @Around("call (long System.currentTimeMillis())")
  70. public long aroundSystemTime(ProceedingJoinPoint joinPoint) throws Throwable {
  71. return ((Long) joinPoint.proceed()) + timeOffsetMillis;
  72. }
  73. }
  74.  
  75. <aspectj>
  76. <aspects>
  77. <aspect name="com.mypackage.TweakSystemAspects"/>
  78. </aspects>
  79. <weaver options="-nowarn -Xlint:ignore"/>
  80. <!-- During testing this was useful, but I didn't want all that output normally. -->
  81. <!--<weaver options="-verbose -showWeaveInfo"/>-->
  82. </aspectj>
  83.  
  84. <project ...>
  85. ...
  86. <properties>
  87. ...
  88. <version.aspectj>1.8.10</version.aspectj>
  89. <properties>
  90.  
  91. <dependencies>
  92. ...
  93. <dependency>
  94. <groupId>org.aspectj</groupId>
  95. <artifactId>aspectjrt</artifactId>
  96. <version>${version.aspectj}</version>
  97. <scope>test</scope>
  98. </dependency>
  99. </dependencies>
  100.  
  101. <build>
  102. <plugins>
  103. ...
  104. <plugin>
  105. <artifactId>maven-surefire-plugin</artifactId>
  106. <configuration>
  107. <!-- For Load Time Weaving of our AspectJ helper code -->
  108. <argLine>-javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${version.aspectj}/aspectjweaver-${version.aspectj}.jar</argLine>
  109. ...
  110. </configuration>
  111. </plugin>
  112. </plugins>
  113. </build>
  114. ...
  115. </project>
Add Comment
Please, Sign In to add comment