-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix AspectJ basics #137
Merged
Merged
Fix AspectJ basics #137
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e052462
Centrally version-manage JUnit 4.13.2, also for tests
kriegaex 2ba3c75
Bump AspectJ to 1.9.7.M3, supporting Java 15+16
kriegaex cec1977
Fix basic AspectJ compiler functionality + add integration test
kriegaex 3cbd1af
Activate 'streamLogsOnFailures' for Maven Invoker
kriegaex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
plexus-compiler-its/src/main/it/aspectj-compiler/invoker.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
invoker.java.version = 1.8+ | ||
invoker.goals = clean test | ||
#invoker.buildResult = failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one | ||
~ or more contributor license agreements. See the NOTICE file | ||
~ distributed with this work for additional information | ||
~ regarding copyright ownership. The ASF licenses this file | ||
~ to you under the Apache License, Version 2.0 (the | ||
~ "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<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.apache.maven.plugins.compiler.it</groupId> | ||
<artifactId>aspectj-compiler</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<configuration> | ||
<compilerId>aspectj</compilerId> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-compiler-api</artifactId> | ||
<version>@pom.version@</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.plexus</groupId> | ||
<artifactId>plexus-compiler-aspectj</artifactId> | ||
<version>@pom.version@</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>@junit.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.aspectj</groupId> | ||
<artifactId>aspectjrt</artifactId> | ||
<version>@aspectj.version@</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
12 changes: 12 additions & 0 deletions
12
plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.acme; | ||
|
||
public class Application { | ||
public static void main(String[] args) { | ||
System.out.println("Running application"); | ||
new Application().greet(args[0]); | ||
} | ||
|
||
public String greet(String name) { | ||
return "Hello " + name; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...piler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyAnnotationDrivenAspect.aj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.acme; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
|
||
@Aspect | ||
public class MyAnnotationDrivenAspect { | ||
@Before("execution(static * *(..)) && within(Application)") | ||
public void myAdvice(JoinPoint joinPoint) { | ||
System.out.println(joinPoint); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyNativeAspect.aj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.acme; | ||
|
||
public aspect MyNativeAspect { | ||
before() : execution(!static * *(..)) && within(Application) { | ||
System.out.println(thisJoinPoint); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ompiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/do-not-try-to-compile.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
The Apache Maven Compiler (MC) API only allows a single source file extension, such as '.java'. | ||
The AspectJ Compiler (AJC) should consider two default extensions, though: '.java' and '.aj'. | ||
In order to achieve that, the Plexus AJC component tells MC to give it all files, | ||
subsequently filtering for those two extensions. | ||
|
||
The purpose of this file is to make sure that even though MC finds it in the source folder, | ||
Plexus AJC filters it out and AJC does not try to compile it. |
19 changes: 19 additions & 0 deletions
19
plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.acme; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class ApplicationTest { | ||
@Test | ||
public void testGreet() { | ||
assertEquals("Hello Jane", new Application().greet("Jane")); | ||
} | ||
|
||
@Test | ||
public void testMain() { | ||
Application.main(new String[] { "Joe" }); | ||
assertTrue(true); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/TestAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.acme; | ||
|
||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
|
||
@Aspect | ||
public class TestAspect { | ||
@Before("call(* *(..)) && !within(TestAspect)") | ||
public void beforeCall(JoinPoint joinPoint) { | ||
System.out.println(joinPoint); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
plexus-compiler-its/src/main/it/aspectj-compiler/verify.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
def logFile = new File( basedir, 'build.log' ) | ||
assert logFile.exists() | ||
content = logFile.text.normalize() | ||
|
||
def junitLog = """Running org.acme.ApplicationTest | ||
call(String org.acme.Application.greet(String)) | ||
execution(String org.acme.Application.greet(String)) | ||
call(void org.junit.Assert.assertEquals(Object, Object)) | ||
call(void org.acme.Application.main(String[])) | ||
execution(void org.acme.Application.main(String[])) | ||
Running application | ||
execution(String org.acme.Application.greet(String)) | ||
call(void org.junit.Assert.assertTrue(boolean)) | ||
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0""".normalize() | ||
|
||
assert content.contains( junitLog ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When searching for the problem in the IT earlier today, I noticed that the debug output was confusing me more than helping me. I think, it is better to activate it on a case-by-case basis. The standard build also does not run in Maven debug mode.