Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
Spoon seems to take package-info.java as containing a type definition, and as the project contains many modules, it takes it (and other package-info.java) as multiple conflicting type definitions.
File pom = new File("path/to/aws-sdk-java/pom.xml");
MavenLauncher launcher = new MavenLauncher(pom.getParentFile().getAbsolutePath(), MavenLauncher.SOURCE_TYPE.APP_SOURCE);
launcher.getEnvironment().setAutoImports(true);
launcher.buildModel();
CtModel model = launcher.getModel();
I get the following problem:
Filename :path/to/aws-sdk-java/aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/package-info.java
COMPILED type(s)
1 PROBLEM(s) detected
- Pb(323) The type package-info is already defined
The offending file contains:
/*
* Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.
*/
package com.amazonaws.metrics;
but weirdly enough it seems to be interpreted as an interface declaration.
Here is the String value of the corresponding CompilationUnitDeclaration:
Problem
Spoon seems to take
package-info.java
as containing a type definition, and as the project contains many modules, it takes it (and other package-info.java) as multiple conflicting type definitions.Reproduction steps
On project
aws-sdk-java
When trying to build a spoon model:
I get the following problem:
The offending file contains:
but weirdly enough it seems to be interpreted as an interface declaration. Here is the String value of the corresponding CompilationUnitDeclaration: