├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── appveyor.yml
├── eclipse-formatter.xml
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── org
│ │ │ └── walkmod
│ │ │ ├── AsciiTableWidth.java
│ │ │ ├── ChainAdapter.java
│ │ │ ├── ChainAdapterFactory.java
│ │ │ ├── ChainInvocation.java
│ │ │ ├── ChainReader.java
│ │ │ ├── ChainWalker.java
│ │ │ ├── ChainWalkerAdapter.java
│ │ │ ├── ChainWalkerInvocation.java
│ │ │ ├── ChainWriter.java
│ │ │ ├── ConfigurationAdapter.java
│ │ │ ├── Converter.java
│ │ │ ├── Options.java
│ │ │ ├── OptionsBuilder.java
│ │ │ ├── Preparer.java
│ │ │ ├── Resource.java
│ │ │ ├── ResourceModifier.java
│ │ │ ├── Result.java
│ │ │ ├── WalkModDispatcher.java
│ │ │ ├── WalkModFacade.java
│ │ │ ├── WalkmodCommand.java
│ │ │ ├── commands
│ │ │ ├── AbstractChainCommand.java
│ │ │ ├── AddCfgProviderCommand.java
│ │ │ ├── AddExcludesCommand.java
│ │ │ ├── AddIncludesCommand.java
│ │ │ ├── AddModuleCommand.java
│ │ │ ├── AddParamCommand.java
│ │ │ ├── AddPluginCommand.java
│ │ │ ├── AddTransformationCommand.java
│ │ │ ├── ApplyCommand.java
│ │ │ ├── AsciiTableAware.java
│ │ │ ├── CheckCommand.java
│ │ │ ├── Command.java
│ │ │ ├── HelpCommand.java
│ │ │ ├── InitCommand.java
│ │ │ ├── InspectCommand.java
│ │ │ ├── InstallCommand.java
│ │ │ ├── JSONConverter.java
│ │ │ ├── PatchCommand.java
│ │ │ ├── PrintChainsCommand.java
│ │ │ ├── PrintModulesCommand.java
│ │ │ ├── PrintPluginsCommand.java
│ │ │ ├── PrintProvidersCommand.java
│ │ │ ├── PrintTransformationsCommand.java
│ │ │ ├── RemoveChainCommand.java
│ │ │ ├── RemoveExcludesCommand.java
│ │ │ ├── RemoveIncludesCommand.java
│ │ │ ├── RemoveModuleCommand.java
│ │ │ ├── RemovePluginCommand.java
│ │ │ ├── RemoveProviderCommand.java
│ │ │ ├── RemoveTransformationCommand.java
│ │ │ ├── SetReaderCommand.java
│ │ │ ├── SetWriterCommand.java
│ │ │ └── VersionCommand.java
│ │ │ ├── conf
│ │ │ ├── BeanFactoryProvider.java
│ │ │ ├── ConfigurationException.java
│ │ │ ├── ConfigurationManager.java
│ │ │ ├── ConfigurationProvider.java
│ │ │ ├── DomConstants.java
│ │ │ ├── DummyConfigurationProvider.java
│ │ │ ├── ExecutionModeEnum.java
│ │ │ ├── Initializer.java
│ │ │ ├── ProjectConfigurationProvider.java
│ │ │ ├── entities
│ │ │ │ ├── BeanDefinition.java
│ │ │ │ ├── ChainConfig.java
│ │ │ │ ├── Configuration.java
│ │ │ │ ├── InitializerConfig.java
│ │ │ │ ├── JSONConfigParser.java
│ │ │ │ ├── MergePolicyConfig.java
│ │ │ │ ├── ParserConfig.java
│ │ │ │ ├── PluginConfig.java
│ │ │ │ ├── PropertyDefinition.java
│ │ │ │ ├── ProviderConfig.java
│ │ │ │ ├── ReaderConfig.java
│ │ │ │ ├── TransformationConfig.java
│ │ │ │ ├── WalkerConfig.java
│ │ │ │ ├── WriterConfig.java
│ │ │ │ └── impl
│ │ │ │ │ ├── BeanDefinitionImpl.java
│ │ │ │ │ ├── ChainConfigImpl.java
│ │ │ │ │ ├── ConfigurationImpl.java
│ │ │ │ │ ├── InitializerConfigImpl.java
│ │ │ │ │ ├── MergePolicyConfigImpl.java
│ │ │ │ │ ├── ParserConfigImpl.java
│ │ │ │ │ ├── PluginConfigImpl.java
│ │ │ │ │ ├── PropertyDefinitionImpl.java
│ │ │ │ │ ├── ProviderConfigImpl.java
│ │ │ │ │ ├── TransformationConfigImpl.java
│ │ │ │ │ ├── WalkerConfigImpl.java
│ │ │ │ │ └── WriterConfigImpl.java
│ │ │ └── providers
│ │ │ │ ├── AbstractChainConfigurationProvider.java
│ │ │ │ ├── ConfigurationAction.java
│ │ │ │ ├── DynamicConfigurationProvider.java
│ │ │ │ ├── DynamicModulesConfigurationProvider.java
│ │ │ │ ├── ExecutionModeProvider.java
│ │ │ │ ├── IvyConfigurationProvider.java
│ │ │ │ ├── LanguageConfigurationProvider.java
│ │ │ │ ├── PluginsConfigurationProvider.java
│ │ │ │ ├── SpringConfigurationProvider.java
│ │ │ │ ├── WritersConfigurationProvider.java
│ │ │ │ ├── XMLConfigurationProvider.java
│ │ │ │ ├── YAMLConfigurationProvider.java
│ │ │ │ ├── xml
│ │ │ │ ├── AbstractXMLConfigurationAction.java
│ │ │ │ ├── AddChainXMLAction.java
│ │ │ │ ├── AddConfigurationParameterXMLAction.java
│ │ │ │ ├── AddIncludesOrExcludesXMLAction.java
│ │ │ │ ├── AddModulesXMLAction.java
│ │ │ │ ├── AddPluginXMLAction.java
│ │ │ │ ├── AddProviderConfigXMLAction.java
│ │ │ │ ├── AddTransformationXMLAction.java
│ │ │ │ ├── RemoveChainsXMLAction.java
│ │ │ │ ├── RemoveIncludesOrExcludesXMLAction.java
│ │ │ │ ├── RemoveModulesXMLAction.java
│ │ │ │ ├── RemovePluginXMLAction.java
│ │ │ │ ├── RemoveProvidersXMLAction.java
│ │ │ │ ├── RemoveTransformationXMLAction.java
│ │ │ │ ├── SetReaderXMLAction.java
│ │ │ │ └── SetWriterXMLAction.java
│ │ │ │ └── yml
│ │ │ │ ├── AbstractYMLConfigurationAction.java
│ │ │ │ ├── AddChainYMLAction.java
│ │ │ │ ├── AddConfigurationParameterYMLAction.java
│ │ │ │ ├── AddIncludesOrExcludesYMLAction.java
│ │ │ │ ├── AddModulesYMLAction.java
│ │ │ │ ├── AddProviderConfigYMLAction.java
│ │ │ │ ├── AddTransformationYMLAction.java
│ │ │ │ ├── RemoveChainsYMLAction.java
│ │ │ │ ├── RemoveIncludesOrExcludesYMLAction.java
│ │ │ │ ├── RemoveModulesYMLAction.java
│ │ │ │ ├── RemovePluginYMLAction.java
│ │ │ │ ├── RemoveProvidersYMLAction.java
│ │ │ │ ├── RemoveTransformationYMLAction.java
│ │ │ │ ├── SetReaderYMLAction.java
│ │ │ │ └── SetWriterYMLAction.java
│ │ │ ├── exceptions
│ │ │ ├── InvalidConfigurationException.java
│ │ │ ├── InvalidImportException.java
│ │ │ ├── InvalidTransformationRuleException.java
│ │ │ └── WalkModException.java
│ │ │ ├── impl
│ │ │ ├── DefaultChainAdapter.java
│ │ │ ├── DefaultChainAdapterFactory.java
│ │ │ ├── DefaultChainInvocation.java
│ │ │ ├── DefaultChainWalkerAdapter.java
│ │ │ ├── DefaultChainWalkerInvocation.java
│ │ │ └── DefaultConfigurationAdapter.java
│ │ │ ├── patches
│ │ │ ├── JsonPatchFormatter.java
│ │ │ ├── Patch.java
│ │ │ ├── PatchFormat.java
│ │ │ ├── PatchFormatter.java
│ │ │ ├── Patches.java
│ │ │ └── RawPatchFormatter.java
│ │ │ ├── query
│ │ │ ├── QueryEngine.java
│ │ │ ├── QueryEngineAware.java
│ │ │ └── ScriptingQueryEngine.java
│ │ │ ├── readers
│ │ │ └── DefaultFileReader.java
│ │ │ ├── scripting
│ │ │ └── ScriptProcessor.java
│ │ │ ├── templates
│ │ │ ├── DefaultTemplateVisitor.java
│ │ │ ├── TemplateEngine.java
│ │ │ └── TemplatesAware.java
│ │ │ ├── util
│ │ │ ├── ClassLoaderUtil.java
│ │ │ ├── DomHelper.java
│ │ │ ├── FileResource.java
│ │ │ └── location
│ │ │ │ ├── Locatable.java
│ │ │ │ ├── Location.java
│ │ │ │ ├── LocationAttributes.java
│ │ │ │ ├── LocationImpl.java
│ │ │ │ └── LocationUtils.java
│ │ │ ├── walkers
│ │ │ ├── AbstractWalker.java
│ │ │ ├── ChangeLogPrinter.java
│ │ │ ├── ParseException.java
│ │ │ ├── Parser.java
│ │ │ ├── ParserAware.java
│ │ │ ├── VisitorContext.java
│ │ │ └── VisitorMessage.java
│ │ │ └── writers
│ │ │ ├── AbstractFileWriter.java
│ │ │ ├── AbstractPatchWriter.java
│ │ │ ├── StringWriter.java
│ │ │ ├── Summary.java
│ │ │ └── VisitorMessagesWriter.java
│ ├── license-header.txt
│ └── resources
│ │ ├── walkmod-1.0.dtd
│ │ ├── walkmod-1.1.dtd
│ │ ├── walkmod-lang-1.0.dtd
│ │ └── walkmod-plugins-1.0.dtd
└── test
│ ├── java
│ └── org
│ │ └── walkmod
│ │ ├── AbstractWalkmodExecutionTest.java
│ │ ├── OptionsTest.java
│ │ ├── ScriptEngineExecutionTest.java
│ │ ├── WalkmodDispatcherTest.java
│ │ ├── WalkmodFacadeTest.java
│ │ ├── conf
│ │ └── providers
│ │ │ ├── LanguageConfigurationProviderTest.java
│ │ │ ├── PluginsConfigurationProviderTest.java
│ │ │ ├── XMLConfigurationProviderTest.java
│ │ │ └── YAMLConfigurationProviderTest.java
│ │ ├── util
│ │ └── FileResourceTest.java
│ │ ├── utils
│ │ └── TestUtils.java
│ │ └── writers
│ │ └── AbstractFileWriterTest.java
│ └── resources
│ ├── add-mvn
│ └── walkmod.xml
│ ├── add-script
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── Foo.java
│ └── walkmod.xml
│ ├── add-template
│ ├── jpa-id.groovy
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── foo
│ │ │ └── Foo.java
│ └── walkmod.xml
│ ├── different-folders
│ ├── pom.xml
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── Foo.java
│ └── walkmod.xml
│ ├── multimodule
│ ├── module1
│ │ ├── pom.xml
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── java
│ │ │ │ └── Bar.java
│ │ └── walkmod.xml
│ ├── module2
│ │ ├── pom.xml
│ │ ├── src
│ │ │ └── main
│ │ │ │ └── java
│ │ │ │ └── Foo.java
│ │ └── walkmod.xml
│ ├── pom.xml
│ └── walkmod.xml
│ ├── multimodulewithoutconfig
│ ├── module1
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── Bar.java
│ ├── module2
│ │ ├── pom.xml
│ │ └── src
│ │ │ └── main
│ │ │ └── java
│ │ │ └── Foo.java
│ └── pom.xml
│ ├── scripts
│ ├── myscript.groovy
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── Foo.java
│ └── walkmod.xml
│ ├── simple
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── Foo.java
│ └── walkmod.yml
│ ├── templates
│ └── jpa-id.groovy
│ ├── testFiles
│ ├── pom.xml
│ └── walkmod.xml
│ └── yaml
│ ├── basic.yml
│ ├── chains.yml
│ └── walkmod.yml
└── walkmod.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /.settings/
2 | /target/
3 | /.classpath
4 | /.project
5 | *.iml
6 | .idea
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | sudo: false
3 | jdk:
4 | - oraclejdk8
5 | - openjdk7
6 | install:
7 | - mvn package -DskipTests=true -Dmaven.javadoc.skip=true -B -V
8 | script:
9 | - mvn test
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/walkmod/walkmod-core) [](https://ci.appveyor.com/project/rpau/walkmod-core)
2 |
3 | walkmod: To Fix Java Static Coding Analysis Issues
4 | ==================================================
5 |
6 | WalkMod, is an open source tool to share and apply code conventions by automatic quick fixes for coding style issues.
7 |
8 | WalkMod is *language agnostic* and *platform agnostic*, since it can be extended to support multiple programming languages and runs in any platform, since it is coded in Java. However, the only current supported programming language is Java.
9 |
10 | WalkMod began as an open source framework to run code transformations. It benefits directly from the experience
11 | accumulated over several years of large-scale projects to support multiple quick fixes for existing static code analysis tools.
12 |
13 |
14 |
15 |
16 |
17 | Getting started
18 | ===============
19 | Docker can be installed either on your computer or in any CI tool to ensure your code style before merging changes. To get started, [check out the installation instructions in the documentation](https://docs.walkmod.com#installation).
20 |
21 | Usage examples
22 | ==============
23 |
24 | WalkMod can be used to run short-lived commands or by using an static configuration.
25 |
26 | You can find a [list of real-world
27 | examples](http://docs.walkmod.com#quickfixes) in the
28 | documentation.
29 |
30 | Under the hood
31 | --------------
32 |
33 | Under the hood, WalkMod is built on the following components:
34 |
35 | * The [ivy](http://ant.apache.org/ivy/) engine to download plugins from Maven repositories.
36 | * The [Spring Framework](http://spring.io/) to support IoC.
37 |
38 |
39 | Contributing to WalkMod
40 | =======================
41 |
42 | Want to hack on WalkMod? Awesome! The `org.walkmod.WalkmodFacade` can help you to
43 | invoke the available commands by API.
44 |
45 | If you want to hack on this, fork it, improve it and send me a pull request.
46 |
47 | To get started using it, just clone it and call mvn install.
48 |
49 |
50 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: '{build}'
2 | skip_tags: true
3 | clone_depth: 10
4 | environment:
5 | matrix:
6 | - JAVA_HOME: C:\Program Files\Java\jdk1.7.0
7 | - JAVA_HOME: C:\Program Files\Java\jdk1.8.0
8 | install:
9 | - ps: >-
10 | $MVNDIR = 'C:\bin\apache-maven-3.3.1\'
11 |
12 | if(!(Test-Path -Path $MVNDIR )){
13 | Write-Host (Test-Path -Path $MVNDIR)
14 | Write-Host 'Installing Maven'
15 | cinst maven -Version 3.3.1
16 | } else {
17 | Write-Host 'Found Maven cached installation'
18 | }
19 | # Note: env variables are not correctly updated by choco (setting it manually)
20 | - cmd: SET PATH=C:\bin\apache-maven-3.3.1\bin;%JAVA_HOME%\bin;%PATH%;
21 | - cmd: mvn --version
22 | - cmd: java -version
23 | build_script:
24 | - mvn clean package -B -Dmaven.test.skip=true -Dmaven.javadoc.skip=true
25 | test_script:
26 | - mvn test -B
27 | cache:
28 | - C:\bin\apache-maven-3.3.1\
29 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.ChainConfig;
21 | import org.walkmod.exceptions.WalkModException;
22 |
23 | public interface ChainAdapter {
24 |
25 | public void setName(String name);
26 |
27 | public String getName();
28 |
29 | public void setChainConfig(ChainConfig config);
30 |
31 | public ChainConfig getChainConfig();
32 |
33 | public ChainInvocation getChainInvocation();
34 |
35 | public void setChainInvocation(ChainInvocation ai);
36 |
37 | public Resource> getResource();
38 |
39 | public void setResource(Resource> model);
40 |
41 | public Map getParams();
42 |
43 | public void setParams(Map params);
44 |
45 | public ChainWalkerAdapter getWalkerAdapter();
46 |
47 | public void setWalkerAdapter(ChainWalkerAdapter walkerAdapter);
48 |
49 | public void setChainWriter(ChainWriter writer);
50 |
51 | public ChainWriter getChainWriter();
52 |
53 | public void prepare() throws WalkModException;
54 |
55 | public void execute() throws WalkModException;
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainAdapterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import org.walkmod.conf.entities.Configuration;
19 |
20 | public interface ChainAdapterFactory {
21 |
22 | public ChainAdapter createChainProxy(Configuration configuration, String chain);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainInvocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import org.walkmod.exceptions.WalkModException;
19 |
20 | public interface ChainInvocation {
21 |
22 | public void init(ChainAdapter chainAdapter);
23 |
24 | public void invoke() throws WalkModException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public abstract class ChainReader {
19 |
20 | private String path;
21 |
22 | private String[] includes;
23 |
24 | private String[] excludes;
25 |
26 | public ChainReader() {
27 | }
28 |
29 | public ChainReader(String path) {
30 | setPath(path);
31 | }
32 |
33 | public String getPath() {
34 | return path;
35 | }
36 |
37 | public void setPath(String path) {
38 | this.path = path;
39 | }
40 |
41 | public String[] getIncludes() {
42 | return includes;
43 | }
44 |
45 | public void setIncludes(String[] includes) {
46 | this.includes = includes;
47 | }
48 |
49 | public String[] getExcludes() {
50 | return excludes;
51 | }
52 |
53 | public void setExcludes(String[] excludes) {
54 | this.excludes = excludes;
55 | }
56 |
57 | public abstract Resource> read() throws Exception;
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainWalker.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import java.util.Collection;
19 | import java.util.List;
20 |
21 | import org.walkmod.conf.entities.ChainConfig;
22 | import org.walkmod.walkers.ParserAware;
23 | import org.walkmod.walkers.VisitorMessage;
24 |
25 | public interface ChainWalker extends ParserAware {
26 |
27 | public void setResource(Resource> resource);
28 |
29 | public void setVisitors(List visitor);
30 |
31 | public void setWriter(Object writer);
32 |
33 | public void setRootNamespace(String namespace);
34 |
35 | public void setChainConfig(ChainConfig ac);
36 |
37 | public void setConstraintProviders(List constraints);
38 |
39 | public List getConstraintProviders();
40 |
41 | public String getRootNamespace();
42 |
43 | public List getVisitors();
44 |
45 | public Object getWriter();
46 |
47 | public void execute() throws Exception;
48 |
49 | public Collection getVisitorMessages();
50 |
51 | public int getNumModifications();
52 |
53 | public int getNumAdditions();
54 |
55 | public int getNumDeletions();
56 |
57 | public boolean reportChanges();
58 |
59 | public void setReportChanges(boolean reportChanges);
60 |
61 | public boolean hasChanges();
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainWalkerAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import java.util.Collection;
19 |
20 | import org.walkmod.conf.entities.TransformationConfig;
21 | import org.walkmod.conf.entities.WalkerConfig;
22 | import org.walkmod.exceptions.WalkModException;
23 |
24 | public interface ChainWalkerAdapter {
25 |
26 | public String getName();
27 |
28 | public void setName(String name);
29 |
30 | public void setTransformationConfig(Collection config);
31 |
32 | public Collection getTransformationConfig();
33 |
34 | public Resource> getModel();
35 |
36 | public void setWalker(ChainWalker walker);
37 |
38 | public ChainWalker getWalker();
39 |
40 | public void setWalkerInvocation(ChainWalkerInvocation ta);
41 |
42 | public ChainWalkerInvocation getWalkerInvocation();
43 |
44 | public ChainAdapter getArchitecture();
45 |
46 | public void setArchitectureProxy(ChainAdapter ap);
47 |
48 | public void prepare() throws WalkModException;
49 |
50 | public void execute() throws WalkModException;
51 |
52 | public void setWalkerConfig(WalkerConfig config);
53 |
54 | public WalkerConfig getWalkerConfig();
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainWalkerInvocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import org.walkmod.exceptions.WalkModException;
19 |
20 | public interface ChainWalkerInvocation {
21 |
22 | public void init(ChainWalkerAdapter transformation);
23 |
24 | public void invoke() throws WalkModException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ChainWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import java.io.Closeable;
19 | import java.io.Flushable;
20 |
21 | import org.walkmod.walkers.VisitorContext;
22 |
23 | public interface ChainWriter extends Closeable, Flushable {
24 |
25 | public String getPath();
26 |
27 | public void setPath(String path);
28 |
29 | public void setExcludes(String[] excludes);
30 |
31 | public String[] getExcludes();
32 |
33 | public void setIncludes(String[] includes);
34 |
35 | public String[] getIncludes();
36 |
37 | public void write(Object n, VisitorContext vc) throws Exception;
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ConfigurationAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import org.walkmod.conf.entities.Configuration;
19 |
20 | public interface ConfigurationAdapter {
21 |
22 | public void setConfiguration(Configuration config);
23 |
24 | public Configuration getConfiguration();
25 |
26 | public void prepare();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/Converter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public interface Converter {
19 |
20 | public M convert(T element);
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/Preparer.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public interface Preparer {
19 |
20 | public void prepare() throws Exception;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/Resource.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public interface Resource extends Iterable {
19 |
20 | public String getNearestNamespace(Object element, String regexSeparator);
21 |
22 | public String getOwnerNamespace(Object element, String regexSeparator);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/ResourceModifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public interface ResourceModifier {
19 |
20 | public void modify() throws Exception;
21 |
22 | public void setResource(Resource> resource);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/Result.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | public interface Result {
19 |
20 | public void render() throws Exception;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/WalkmodCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod;
17 |
18 | import java.io.File;
19 |
20 | public interface WalkmodCommand {
21 |
22 | public void execute(Options options, File executionDir, String... chains) throws Exception;
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/AddExcludesCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Adds exclude rules to the configuration.")
28 | public class AddExcludesCommand implements Command {
29 |
30 | @Parameter(description = "List of excludes to add", required = true)
31 | private List excludes;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
39 | private Boolean printErrors = false;
40 |
41 | @Parameter(names = { "--chain" }, description = "The chain name")
42 | private String chain = "default";
43 |
44 | @Parameter(names = { "--setToReader" }, description = "If the filter is applied in the reader")
45 | private boolean setToReader = true;
46 |
47 | @Parameter(names = { "--setToWriter" }, description = "If the filter is applied in the writer")
48 | private boolean setToWriter = false;
49 |
50 | @Parameter(names = { "--recursive", "-R" }, description = "Adds the transformation to all submodules")
51 | private boolean recursive = false;
52 |
53 | public AddExcludesCommand(JCommander jcommander) {
54 | this.jcommander = jcommander;
55 | }
56 |
57 | @Override
58 | public void execute() throws Exception {
59 | if (help) {
60 | jcommander.usage("add-excludes");
61 | } else {
62 |
63 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
64 | facade.addExcludesToChain(chain, excludes, recursive, setToReader, setToWriter);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/AddIncludesCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Adds includes rules to the configuration.")
28 | public class AddIncludesCommand implements Command {
29 |
30 | @Parameter(description = "List of includes to add", required = true)
31 | private List includes;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
39 | private Boolean printErrors = false;
40 |
41 | @Parameter(names = { "--chain" }, description = "The chain name")
42 | private String chain = "default";
43 |
44 | @Parameter(names = { "--setToReader" }, description = "If the filter is applied in the reader")
45 | private boolean setToReader = true;
46 |
47 | @Parameter(names = { "--setToWriter" }, description = "If the filter is applied in the writer")
48 | private boolean setToWriter = false;
49 |
50 | @Parameter(names = { "--recursive", "-R" }, description = "Adds the transformation to all submodules")
51 | private boolean recursive = false;
52 |
53 | public AddIncludesCommand(JCommander jcommander) {
54 | this.jcommander = jcommander;
55 | }
56 |
57 | public AddIncludesCommand(List includes, boolean recursive, boolean setToReader, boolean setToWriter) {
58 | this.includes = includes;
59 | this.recursive = recursive;
60 | this.setToReader = setToReader;
61 | this.setToWriter = setToWriter;
62 | }
63 |
64 | @Override
65 | public void execute() throws Exception {
66 | if (help) {
67 | jcommander.usage("add-includes");
68 | } else {
69 |
70 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
71 | facade.addIncludesToChain(chain, includes, recursive, setToReader, setToWriter);
72 | }
73 |
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/AddModuleCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Adds modules (walkmod subprojects) to the configuration.")
28 | public class AddModuleCommand implements Command {
29 |
30 | @Parameter(description = "List of modules to add", required = true)
31 | private List modules;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
39 | private Boolean printErrors = false;
40 |
41 | public AddModuleCommand(JCommander jcommander) {
42 | this.jcommander = jcommander;
43 | }
44 |
45 | public AddModuleCommand(List modules) {
46 | this.modules = modules;
47 | }
48 |
49 | @Override
50 | public void execute() throws Exception {
51 | if (help) {
52 | jcommander.usage("add-module");
53 | } else {
54 |
55 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
56 | facade.addModules(modules);
57 | }
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/AddPluginCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.LinkedList;
19 | import java.util.List;
20 |
21 | import org.walkmod.OptionsBuilder;
22 | import org.walkmod.WalkModFacade;
23 | import org.walkmod.conf.entities.PluginConfig;
24 | import org.walkmod.conf.entities.impl.PluginConfigImpl;
25 |
26 | import com.beust.jcommander.JCommander;
27 | import com.beust.jcommander.Parameter;
28 | import com.beust.jcommander.Parameters;
29 |
30 | @Parameters(separators = "=", commandDescription = "Adds plugin to the configuration file.")
31 | public class AddPluginCommand implements Command {
32 |
33 | @Parameter(description = "List of plugin identifiers separated by spaces.", required = true)
34 | private List plugins = null;
35 |
36 | @Parameter(names = "--help", help = true, hidden = true)
37 | private boolean help;
38 |
39 | private JCommander command;
40 |
41 | @Parameter(names = {"--recursive", "-R"}, description = "Adds the plugin to all submodules")
42 | private boolean recursive = false;
43 |
44 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
45 | private Boolean printErrors = false;
46 |
47 | public AddPluginCommand(JCommander command) {
48 | this.command = command;
49 | }
50 |
51 | public AddPluginCommand(List plugins) {
52 | this.plugins = plugins;
53 | }
54 |
55 | public List build() {
56 | List result = new LinkedList();
57 | for (String plugin : plugins) {
58 | PluginConfig pluginConfig = new PluginConfigImpl(plugin);
59 |
60 | result.add(pluginConfig);
61 |
62 | }
63 | return result;
64 | }
65 |
66 | @Override
67 | public void execute() throws Exception {
68 | if (help) {
69 | command.usage("add-plugin");
70 | } else {
71 |
72 | List list = build();
73 | for (PluginConfig pc : list) {
74 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
75 | facade.addPluginConfig(pc, recursive);
76 | }
77 |
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/ApplyCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import org.walkmod.WalkModFacade;
19 |
20 | import com.beust.jcommander.JCommander;
21 | import com.beust.jcommander.Parameters;
22 |
23 | @Parameters(separators = "=", commandDescription = "Upgrades your code to apply all your code transformations.")
24 | public class ApplyCommand extends AbstractChainCommand implements Command {
25 |
26 | private JCommander command;
27 |
28 | public ApplyCommand(JCommander command) {
29 | this.command = command;
30 | }
31 |
32 | @Override
33 | public void execute() throws Exception {
34 | if (isHelpNeeded()) {
35 | command.usage("apply");
36 | } else {
37 | WalkModFacade facade = new WalkModFacade(buildOptions());
38 | String[] params = new String[getParameters().size()];
39 | if (params.length == 0) {
40 | facade.apply();
41 | } else {
42 | facade.apply(getParameters().toArray(params));
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/AsciiTableAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import de.vandermeer.asciitable.v2.V2_AsciiTable;
19 |
20 | public interface AsciiTableAware {
21 |
22 | public V2_AsciiTable getTable();
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/CheckCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import org.walkmod.WalkModFacade;
19 |
20 | import com.beust.jcommander.JCommander;
21 | import com.beust.jcommander.Parameters;
22 |
23 | @Parameters(separators = "=", commandDescription = "Checks which classes needs to be modified according your code transformations.")
24 | public class CheckCommand extends AbstractChainCommand implements Command {
25 |
26 | private JCommander command;
27 |
28 | public CheckCommand(JCommander command) {
29 | this.command = command;
30 | }
31 |
32 | @Override
33 | public void execute() throws Exception {
34 | if (isHelpNeeded()) {
35 | command.usage("check");
36 | } else {
37 | WalkModFacade facade = new WalkModFacade(buildOptions());
38 | String[] params = new String[getParameters().size()];
39 | if (params.length == 0) {
40 | facade.check();
41 | } else {
42 | facade.check(getParameters().toArray(params));
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/Command.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | public interface Command {
19 |
20 | public void execute() throws Exception;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/HelpCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.Map;
19 | import java.util.Set;
20 |
21 | import com.beust.jcommander.JCommander;
22 | import com.beust.jcommander.Parameters;
23 |
24 | @Parameters(hidden = true, separators = "=", commandDescription = "Shows the command line tool commands")
25 | public class HelpCommand implements Command {
26 | private JCommander command;
27 |
28 | public HelpCommand(JCommander command) {
29 | this.command = command;
30 | }
31 |
32 | @Override
33 | public void execute() throws Exception {
34 | Map commandList = command.getCommands();
35 | Set goals = commandList.keySet();
36 | System.out.println("Usage: walkmod COMMAND [arg...]");
37 | System.out.println(" walkmod [ -h | --help | -v | --version ]");
38 | System.out.println();
39 | System.out.println("Options:");
40 | for (String goal : goals) {
41 | if (goal.startsWith("--")) {
42 | System.out.printf(" %-13.40s %-40.100s%n", goal, command.getCommandDescription(goal));
43 | }
44 | }
45 | System.out.println();
46 | System.out.println("Commands:");
47 | for (String goal : goals) {
48 | if (!goal.startsWith("--")) {
49 | System.out.printf(" %-13.40s %-40.100s%n", goal, command.getCommandDescription(goal));
50 | }
51 | }
52 | System.out.println();
53 | System.out.println("Run 'walkmod COMMAND --help' for more information on a command.");
54 | // command.usage();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/InitCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import org.walkmod.OptionsBuilder;
19 | import org.walkmod.WalkModFacade;
20 |
21 | import com.beust.jcommander.JCommander;
22 | import com.beust.jcommander.Parameter;
23 | import com.beust.jcommander.Parameters;
24 |
25 | @Parameters(separators = "=", commandDescription = "Creates an empty walkmod configuration file in your favorite format (yml or xml).")
26 | public class InitCommand implements Command {
27 |
28 | @Parameter(names = "--help", help = true, hidden = true)
29 | private boolean help;
30 |
31 | private JCommander command;
32 |
33 | @Parameter(names = { "--format", "-f" }, description = "configuration format")
34 | private String format = "yml";
35 |
36 | public InitCommand(JCommander command) {
37 | this.command = command;
38 | }
39 |
40 | public InitCommand(String format){
41 | this.format = format;
42 | }
43 |
44 | @Override
45 | public void execute() throws Exception {
46 | if (help) {
47 | command.usage("init");
48 | } else {
49 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().configurationFormat(format));
50 | facade.init();
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/InstallCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import org.walkmod.OptionsBuilder;
19 | import org.walkmod.WalkModFacade;
20 |
21 | import com.beust.jcommander.JCommander;
22 | import com.beust.jcommander.Parameter;
23 | import com.beust.jcommander.Parameters;
24 |
25 | @Parameters(separators = "=", commandDescription = "Downloads and installs the specified walkmod plugins and all their dependencies.")
26 | public class InstallCommand implements Command {
27 |
28 | @Parameter(names = "--help", help = true, hidden = true)
29 | private boolean help;
30 |
31 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
32 | private Boolean showException = false;
33 |
34 | private JCommander command;
35 |
36 | public InstallCommand(JCommander command) {
37 | this.command = command;
38 | }
39 |
40 | @Override
41 | public void execute() throws Exception {
42 | if (help) {
43 | command.usage("install");
44 | } else {
45 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(showException));
46 | facade.install();
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/JSONConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import com.beust.jcommander.IStringConverter;
19 | import com.fasterxml.jackson.core.JsonParser;
20 | import com.fasterxml.jackson.databind.JsonNode;
21 | import com.fasterxml.jackson.databind.ObjectMapper;
22 |
23 | public class JSONConverter implements IStringConverter {
24 | private ObjectMapper mapper;
25 |
26 | public JSONConverter(){
27 | mapper = new ObjectMapper();
28 |
29 | mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
30 |
31 | mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
32 | }
33 |
34 | @Override
35 | public JsonNode convert(String value) {
36 | JsonNode node = null;
37 | try {
38 | node = mapper.readTree(value);
39 | } catch (Exception e) {
40 | throw new RuntimeException(e);
41 | }
42 |
43 |
44 | return node;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/PatchCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.WalkModFacade;
21 | import org.walkmod.patches.PatchFormat;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Generates the corresponding patches for all your code transformations.")
28 | public class PatchCommand extends AbstractChainCommand implements Command {
29 |
30 | private JCommander command;
31 |
32 | @Parameter(names = { "-g", "--global" }, description = "Produces a global patch per file")
33 | private boolean patchPerFile = true;
34 |
35 | @Parameter(names = { "-o", "--occurrence" }, description = "Produces a patch per change occurrence")
36 | private boolean patchPerChange = false;
37 |
38 | @Parameter(names = { "-s", "--style" }, description = "Patch style (json or raw)")
39 | private String patchFormat = PatchFormat.RAW.name();
40 |
41 | public PatchCommand(JCommander command) {
42 | this.command = command;
43 | }
44 |
45 | @Override
46 | public void execute() throws Exception {
47 | if (isHelpNeeded()) {
48 | command.usage("patch");
49 | } else {
50 |
51 | Map dynParams = getDynamicParams();
52 | dynParams.put("patchPerFile", Boolean.toString(patchPerFile));
53 | dynParams.put("patchPerChange", Boolean.toString(patchPerChange));
54 | dynParams.put("patchFormat", patchFormat);
55 |
56 | WalkModFacade facade = new WalkModFacade(buildOptions());
57 | String[] params = new String[getParameters().size()];
58 | if (params.length == 0) {
59 | facade.patch();
60 | } else {
61 | facade.patch(getParameters().toArray(params));
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/PrintModulesCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.apache.log4j.Logger;
21 | import org.walkmod.OptionsBuilder;
22 | import org.walkmod.WalkModFacade;
23 | import org.walkmod.conf.entities.Configuration;
24 |
25 | import com.beust.jcommander.JCommander;
26 | import com.beust.jcommander.Parameter;
27 | import com.beust.jcommander.Parameters;
28 |
29 | import de.vandermeer.asciitable.v2.V2_AsciiTable;
30 |
31 | @Parameters(separators = "=", commandDescription = "Shows the list of modules.")
32 | public class PrintModulesCommand implements Command, AsciiTableAware {
33 |
34 | @Parameter(names = "--help", help = true, hidden = true)
35 | private boolean help;
36 |
37 | private JCommander command;
38 |
39 | private V2_AsciiTable at = null;
40 |
41 | private static Logger log = Logger.getLogger(PrintModulesCommand.class);
42 |
43 | public PrintModulesCommand(JCommander command) {
44 | this.command = command;
45 | }
46 |
47 | @Override
48 | public void execute() throws Exception {
49 | if (help) {
50 | command.usage("modules");
51 | } else {
52 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options());
53 | Configuration cfg = facade.getConfiguration();
54 | if(cfg == null){
55 | log.error("Sorry, the current directory does not contain a walkmod configuration file or it is invalid.");
56 | }
57 | at = new V2_AsciiTable();
58 | at.addRule();
59 | at.addRow("MODULE");
60 | at.addRule();
61 |
62 | if (cfg != null) {
63 | List modules = cfg.getModules();
64 | if (modules != null) {
65 | for (String module : modules) {
66 | at.addRow(module);
67 | }
68 | }
69 | }
70 | at.addRule();
71 |
72 | }
73 | }
74 |
75 | @Override
76 | public V2_AsciiTable getTable() {
77 |
78 | return at;
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/RemoveChainCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Removes chains from the configuration.")
28 | public class RemoveChainCommand implements Command{
29 |
30 | @Parameter(description = "List of chains to remove", required = true)
31 | private List chains;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "--recursive", "-R" }, description = "Remove the chains to all submodules")
39 | private boolean recursive = false;
40 |
41 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
42 | private Boolean printErrors = false;
43 |
44 | public RemoveChainCommand(JCommander jcommander){
45 | this.jcommander = jcommander;
46 | }
47 |
48 | @Override
49 | public void execute() throws Exception {
50 | if (help) {
51 | jcommander.usage("rm-chain");
52 | } else {
53 |
54 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
55 | facade.removeChains(chains, recursive);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/RemoveIncludesCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Removes include rules from the configuration.")
28 | public class RemoveIncludesCommand implements Command {
29 |
30 | @Parameter(description = "List of excludes to remove", required = true)
31 | private List includes;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
39 | private Boolean printErrors = false;
40 |
41 | @Parameter(names = { "--chain" }, description = "The chain name")
42 | private String chain = "default";
43 |
44 | @Parameter(names = { "--setToReader" }, description = "If the filter is applied in the reader")
45 | private boolean setToReader = true;
46 |
47 | @Parameter(names = { "--setToWriter" }, description = "If the filter is applied in the writer")
48 | private boolean setToWriter = false;
49 |
50 | @Parameter(names = { "--recursive", "-R" }, description = "Adds the transformation to all submodules")
51 | private boolean recursive = false;
52 |
53 | public RemoveIncludesCommand(JCommander jcommander) {
54 | this.jcommander = jcommander;
55 | }
56 |
57 | public RemoveIncludesCommand(List includes, String chain, boolean setToReader, boolean setToWriter) {
58 | this.includes = includes;
59 | this.chain = chain;
60 | this.setToReader = setToReader;
61 | this.setToWriter = setToWriter;
62 | }
63 |
64 | @Override
65 | public void execute() throws Exception {
66 | if (help) {
67 | jcommander.usage("rm-includes");
68 | } else {
69 |
70 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
71 | facade.removeIncludesToChain(chain, includes, recursive, setToReader, setToWriter);
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/RemoveModuleCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Removes modules from the configuration.")
28 | public class RemoveModuleCommand implements Command{
29 |
30 | @Parameter(description = "List of modules to remove", required = true)
31 | private List modules;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
39 | private Boolean printErrors = false;
40 |
41 | public RemoveModuleCommand(JCommander jcommander){
42 | this.jcommander = jcommander;
43 | }
44 |
45 | @Override
46 | public void execute() throws Exception {
47 | if (help) {
48 | jcommander.usage("rm-module");
49 | } else {
50 |
51 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
52 | facade.removeModules(modules);
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/RemoveProviderCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Removes configuration providers from the configuration.")
28 | public class RemoveProviderCommand implements Command{
29 |
30 | @Parameter(description = "List of provider identifiers separated by spaces.", required = true)
31 | private List providers = null;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander command;
37 |
38 | @Parameter(names = { "--recursive", "-R" }, description = "Remove the providers to all submodules")
39 | private boolean recursive = false;
40 |
41 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
42 | private Boolean printErrors = false;
43 |
44 | public RemoveProviderCommand(JCommander command) {
45 | this.command = command;
46 | }
47 |
48 |
49 | @Override
50 | public void execute() throws Exception {
51 | if (help) {
52 | command.usage("rm-provider");
53 | } else {
54 |
55 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
56 | facade.removeProviders(providers, recursive);
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/RemoveTransformationCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.OptionsBuilder;
21 | import org.walkmod.WalkModFacade;
22 |
23 | import com.beust.jcommander.JCommander;
24 | import com.beust.jcommander.Parameter;
25 | import com.beust.jcommander.Parameters;
26 |
27 | @Parameters(separators = "=", commandDescription = "Removes a list of transformations from your configuration.")
28 | public class RemoveTransformationCommand implements Command {
29 |
30 | @Parameter(description = "The list of transformation types", required = true)
31 | private List types = null;
32 |
33 | @Parameter(names = "--help", help = true, hidden = true)
34 | private boolean help;
35 |
36 | private JCommander jcommander;
37 |
38 | @Parameter(names = { "--chain" }, description = "The chain name")
39 | private String chain = "default";
40 |
41 | @Parameter(names = {"--recursive", "-R"}, description = "Removes the transformation to all submodules")
42 | private boolean recursive = false;
43 |
44 | @Parameter(names = { "-e", "--verbose" }, description = "Prints the stacktrace of the produced error during the execution")
45 | private Boolean printErrors = false;
46 |
47 | public RemoveTransformationCommand(JCommander jcommander) {
48 | this.jcommander = jcommander;
49 | }
50 |
51 | @Override
52 | public void execute() throws Exception {
53 | if (help) {
54 | jcommander.usage("rm");
55 | } else {
56 | WalkModFacade facade = new WalkModFacade(OptionsBuilder.options().printErrors(printErrors));
57 | facade.removeTransformations(chain, types, recursive);
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/commands/VersionCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.commands;
17 |
18 | import com.beust.jcommander.Parameters;
19 |
20 | @Parameters(hidden = true, separators = "=", commandDescription = "Shows the current version of this tool")
21 | public class VersionCommand implements Command {
22 |
23 | @Override
24 | public void execute() throws Exception {
25 | System.out.println("Walkmod version \"3.0\"");
26 | System.out.println("Java version: " + System.getProperty("java.version"));
27 | System.out.println("Java Home: " + System.getProperty("java.home"));
28 | System.out.println("OS: " + System.getProperty("os.name") + ", Version: " + System.getProperty("os.version"));
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/BeanFactoryProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | public interface BeanFactoryProvider {
19 |
20 | public void loadBeanFactory() throws ConfigurationException;
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/ConfigurationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | public class ConfigurationException extends RuntimeException {
19 |
20 | /**
21 | * Constructs a ConfigurationException
with the specified
22 | * detail message.
23 | *
24 | * @param message
25 | * the detail message.
26 | */
27 | public ConfigurationException(String message) {
28 | super(message);
29 | }
30 |
31 | /**
32 | * Constructs a ConfigurationException
with the specified
33 | * detail message and exception cause.
34 | *
35 | * @param message
36 | * the detail message.
37 | * @param cause
38 | * the wrapped exception
39 | */
40 | public ConfigurationException(String message, Throwable cause) {
41 | super(message, cause);
42 | if (cause != null) {
43 | this.setStackTrace(cause.getStackTrace());
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/ConfigurationProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | import org.walkmod.conf.entities.Configuration;
19 |
20 | public interface ConfigurationProvider {
21 |
22 | public void init(Configuration configuration);
23 |
24 | public void load() throws ConfigurationException;
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/DomConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | import java.util.Collections;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | public class DomConstants {
23 | public final static Map WALKMOD_DTD_MAPPINGS;
24 |
25 | static {
26 | Map mappings = new HashMap();
27 | mappings.put("-//WALKMOD//DTD", "walkmod-1.1.dtd");
28 | mappings.put("-//WALKMOD//DTD//1.0", "walkmod-1.0.dtd");
29 | mappings.put("-//WALKMOD//DTD//1.1", "walkmod-1.1.dtd");
30 | WALKMOD_DTD_MAPPINGS = Collections.unmodifiableMap(mappings);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/ExecutionModeEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | public enum ExecutionModeEnum {
19 |
20 | APPLY, CHECK, PATCH
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/Initializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf;
17 |
18 | public interface Initializer {
19 |
20 | public void execute(ProjectConfigurationProvider provider) throws Exception;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/BeanDefinition.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.List;
19 |
20 | public interface BeanDefinition {
21 |
22 | public String getCategory();
23 |
24 | public String getType();
25 |
26 | public List getProperties();
27 |
28 | public String getDescription();
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/ChainConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface ChainConfig {
21 |
22 | public String getName();
23 |
24 | public void setName(String name);
25 |
26 | public void setParameters(Map parameters);
27 |
28 | public Map getParameters();
29 |
30 | public ReaderConfig getReaderConfig();
31 |
32 | public void setReaderConfig(ReaderConfig model);
33 |
34 | public Configuration getConfiguration();
35 |
36 | public void setConfiguration(Configuration configuration);
37 |
38 | public void setWalkerConfig(WalkerConfig wc);
39 |
40 | public WalkerConfig getWalkerConfig();
41 |
42 | public void setWriterConfig(WriterConfig wc);
43 |
44 | public WriterConfig getWriterConfig();
45 |
46 | public void setPath(String path);
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/InitializerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface InitializerConfig {
21 |
22 | public void setType(String type);
23 |
24 | public String getPluginArtifactId();
25 |
26 | public String getPluginGroupId();
27 |
28 | public void setParams(Map params);
29 |
30 | public String getType();
31 |
32 | public Map getParams();
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/MergePolicyConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface MergePolicyConfig {
21 |
22 | public void setDefaultObjectPolicy(String defaultObjectPolicy);
23 |
24 | public void setDefaultTypePolicy(String defaultTypePolicy);
25 |
26 | public void setName(String name);
27 |
28 | public String getName();
29 |
30 | public String getDefaultTypePolicy();
31 |
32 | public String getDefaultObjectPolicy();
33 |
34 | public void setPolicyEntries(Map policyEntries);
35 |
36 | public Map getPolicyEntries();
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/ParserConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface ParserConfig {
21 |
22 | public String getType();
23 |
24 | public void setType(String type);
25 |
26 | public Map getParameters();
27 |
28 | public void setParameters(Map parameters);
29 |
30 | public Object getParserInstance();
31 |
32 | public void setParserInstance(Object parserInstance);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/PluginConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | public interface PluginConfig {
19 |
20 | public String getGroupId();
21 |
22 | public void setGroupId(String groupId);
23 |
24 | public String getArtifactId();
25 |
26 | public void setArtifactId(String artifactId);
27 |
28 | public String getVersion();
29 |
30 | public void setVersion(String version);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/PropertyDefinition.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | public interface PropertyDefinition {
19 |
20 | public String getType();
21 |
22 | public String getName();
23 |
24 | public String getDefaultValue();
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/ProviderConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface ProviderConfig {
21 |
22 | public String getType();
23 |
24 | public void setType(String type);
25 |
26 | public Map getParameters();
27 |
28 | public void setParameters(Map parameters);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/ReaderConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.ChainReader;
21 |
22 | public class ReaderConfig {
23 |
24 | private String path;
25 |
26 | private String type;
27 |
28 | private ChainReader modelReader;
29 |
30 | private Map parameters;
31 |
32 | private String[] includes;
33 |
34 | private String[] excludes;
35 |
36 | public String getPath() {
37 | return path;
38 | }
39 |
40 | public void setPath(String path) {
41 | this.path = path;
42 | }
43 |
44 | public String getType() {
45 | return type;
46 | }
47 |
48 | public void setType(String type) {
49 | this.type = type;
50 | }
51 |
52 | public Map getParameters() {
53 | return parameters;
54 | }
55 |
56 | public void setParameters(Map parameters) {
57 | this.parameters = parameters;
58 | }
59 |
60 | public ChainReader getModelReader() {
61 | return modelReader;
62 | }
63 |
64 | public void setModelReader(ChainReader modelReader) {
65 | this.modelReader = modelReader;
66 | }
67 |
68 | public String[] getIncludes() {
69 | return includes;
70 | }
71 |
72 | public void setIncludes(String[] includes) {
73 | this.includes = includes;
74 | }
75 |
76 | public String[] getExcludes() {
77 | return excludes;
78 | }
79 |
80 | public void setExcludes(String[] excludes) {
81 | this.excludes = excludes;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/TransformationConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | public interface TransformationConfig {
21 |
22 | public String getName();
23 |
24 | public void setName(String name);
25 |
26 | public String getType();
27 |
28 | public void setType(String visitor);
29 |
30 | public Map getParameters();
31 |
32 | public void setParameters(Map parameters);
33 |
34 | public Object getVisitorInstance();
35 |
36 | public void setVisitorInstance(Object visitorInstance);
37 |
38 | public void isMergeable(boolean isMergeable);
39 |
40 | public boolean isMergeable();
41 |
42 | public void setMergePolicy(String mergePolicy);
43 |
44 | public String getMergePolicy();
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/WalkerConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | import org.walkmod.ChainWalker;
22 |
23 | public interface WalkerConfig {
24 |
25 | public String getType();
26 |
27 | public void setType(String type);
28 |
29 | public List getTransformations();
30 |
31 | public void setTransformations(List transformations);
32 |
33 | public Map getParams();
34 |
35 | public void setParams(Map params);
36 |
37 | public String getRootNamespace();
38 |
39 | public void setRootNamespace(String rootNamespace);
40 |
41 | public void setChainConfig(ChainConfig chainConfig);
42 |
43 | public ChainConfig getChainConfig();
44 |
45 | public ChainWalker getWalker();
46 |
47 | public void setWalker(ChainWalker walker);
48 |
49 | public void setParserConfig(ParserConfig parserConfig);
50 |
51 | public ParserConfig getParserConfig();
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/WriterConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.ChainWriter;
21 |
22 | public interface WriterConfig {
23 |
24 | public String getPath();
25 |
26 | public void setPath(String path);
27 |
28 | public String getType();
29 |
30 | public void setType(String type);
31 |
32 | public void setPatcherType(String type);
33 |
34 | public String getPatcherType();
35 |
36 | public ChainWriter getModelWriter();
37 |
38 | public void setModelWriter(ChainWriter modelWriter);
39 |
40 | public Map getParams();
41 |
42 | public void setParams(Map params);
43 |
44 | public void setExcludes(String[] excludes);
45 |
46 | public String[] getExcludes();
47 |
48 | public void setIncludes(String[] includes);
49 |
50 | public String[] getIncludes();
51 |
52 | public boolean isPatchWriter();
53 |
54 | public void isPatchWriter(boolean isPatchWriter);
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/BeanDefinitionImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.conf.entities.BeanDefinition;
21 | import org.walkmod.conf.entities.PropertyDefinition;
22 |
23 | public class BeanDefinitionImpl implements BeanDefinition{
24 |
25 | private String category;
26 |
27 | private String type;
28 |
29 | private String description ="unavailable";
30 |
31 | private List properties;
32 |
33 | public BeanDefinitionImpl(String category, String type, String description, List properties){
34 | this.category = category;
35 | this.type = type;
36 | if(description != null){
37 | this.description = description;
38 | }
39 | this.properties = properties;
40 | }
41 |
42 | @Override
43 | public String getCategory() {
44 | return category;
45 | }
46 |
47 | @Override
48 | public String getType() {
49 | return type;
50 | }
51 |
52 | @Override
53 | public String getDescription() {
54 | return description;
55 | }
56 |
57 | @Override
58 | public List getProperties() {
59 | return properties;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/InitializerConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.InitializerConfig;
21 |
22 | public class InitializerConfigImpl implements InitializerConfig {
23 |
24 | private String type;
25 |
26 | private Map params;
27 |
28 | @Override
29 | public void setType(String type) {
30 | this.type = type;
31 | }
32 |
33 | @Override
34 | public void setParams(Map params) {
35 | this.params = params;
36 | }
37 |
38 | @Override
39 | public String getType() {
40 | return type;
41 | }
42 |
43 | @Override
44 | public Map getParams() {
45 | return params;
46 | }
47 |
48 | @Override
49 | public String getPluginArtifactId() {
50 |
51 | return type.substring(0, type.indexOf("-initializer"));
52 | }
53 |
54 | @Override
55 | public String getPluginGroupId() {
56 |
57 | return "org.walkmod";
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/MergePolicyConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.MergePolicyConfig;
21 |
22 | public class MergePolicyConfigImpl implements MergePolicyConfig {
23 |
24 | private String defaultObjectPolicy;
25 |
26 | private String defaultTypePolicy;
27 |
28 | private String name;
29 |
30 | private Map policyEntries;
31 |
32 | @Override
33 | public void setDefaultObjectPolicy(String defaultObjectPolicy) {
34 | this.defaultObjectPolicy = defaultObjectPolicy;
35 | }
36 |
37 | @Override
38 | public void setDefaultTypePolicy(String defaultTypePolicy) {
39 | this.defaultTypePolicy = defaultTypePolicy;
40 | }
41 |
42 | @Override
43 | public void setName(String name) {
44 | this.name = name;
45 | }
46 |
47 | @Override
48 | public String getName() {
49 | return name;
50 | }
51 |
52 | @Override
53 | public String getDefaultTypePolicy() {
54 | return defaultTypePolicy;
55 | }
56 |
57 | @Override
58 | public String getDefaultObjectPolicy() {
59 | return defaultObjectPolicy;
60 | }
61 |
62 | @Override
63 | public void setPolicyEntries(Map policyEntries) {
64 | this.policyEntries = policyEntries;
65 | }
66 |
67 | @Override
68 | public Map getPolicyEntries() {
69 | return policyEntries;
70 | }
71 |
72 | @Override
73 | public boolean equals(Object o) {
74 | if (o instanceof MergePolicyConfig) {
75 | String n1 = getName();
76 | String n2 = ((MergePolicyConfig) o).getName();
77 | return n1 != null && n2 != null && n1.equals(n2);
78 | }
79 | return false;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/ParserConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.ParserConfig;
21 |
22 | public class ParserConfigImpl implements ParserConfig {
23 |
24 | private String type;
25 |
26 | private Map parameters;
27 |
28 | private Object parserInstance;
29 |
30 | @Override
31 | public String getType() {
32 | return type;
33 | }
34 |
35 | @Override
36 | public void setType(String type) {
37 | this.type = type;
38 | }
39 |
40 | @Override
41 | public Map getParameters() {
42 | return parameters;
43 | }
44 |
45 | @Override
46 | public void setParameters(Map parameters) {
47 | this.parameters = parameters;
48 | }
49 |
50 | @Override
51 | public Object getParserInstance() {
52 | return parserInstance;
53 | }
54 |
55 | @Override
56 | public void setParserInstance(Object parserInstance) {
57 | this.parserInstance = parserInstance;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/PropertyDefinitionImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import org.walkmod.conf.entities.PropertyDefinition;
19 |
20 | public class PropertyDefinitionImpl implements PropertyDefinition {
21 |
22 | private String type;
23 |
24 | private String name;
25 |
26 | private String defaultValue;
27 |
28 | public PropertyDefinitionImpl(String type, String name, String defaultValue) {
29 | this.name = name;
30 | this.type = type;
31 | this.defaultValue = defaultValue;
32 | }
33 |
34 | @Override
35 | public String getType() {
36 | return type;
37 | }
38 |
39 | @Override
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | @Override
45 | public String getDefaultValue() {
46 | return defaultValue;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/ProviderConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.ProviderConfig;
21 |
22 | public class ProviderConfigImpl implements ProviderConfig {
23 |
24 | private String type;
25 |
26 | private Map parameters;
27 |
28 | @Override
29 | public String getType() {
30 | return type;
31 | }
32 |
33 | @Override
34 | public void setType(String type) {
35 | this.type = type;
36 | }
37 |
38 | @Override
39 | public Map getParameters() {
40 | return parameters;
41 | }
42 |
43 | @Override
44 | public void setParameters(Map parameters) {
45 | this.parameters = parameters;
46 | }
47 |
48 | @Override
49 | public boolean equals(Object o){
50 | if(o instanceof ProviderConfig){
51 | String type2 = ((ProviderConfig) o).getType();
52 | if(type2 == null || type == null){
53 | return type == type2;
54 | }
55 | return type.equals(type2);
56 | }
57 | return false;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/entities/impl/TransformationConfigImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.entities.impl;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.conf.entities.TransformationConfig;
21 |
22 | public class TransformationConfigImpl implements TransformationConfig {
23 |
24 | private String name;
25 |
26 | private String visitor;
27 |
28 | private Map parameters;
29 |
30 | private Object visitorInstance;
31 |
32 | private boolean isMergeable = false;
33 |
34 | private String mergePolicy;
35 |
36 | public TransformationConfigImpl(){}
37 |
38 | public TransformationConfigImpl(String type){
39 | setType(type);
40 | }
41 |
42 | public String getName() {
43 | return name;
44 | }
45 |
46 | public void setName(String name) {
47 | this.name = name;
48 | }
49 |
50 | public Map getParameters() {
51 | return parameters;
52 | }
53 |
54 | public void setParameters(Map parameters) {
55 | this.parameters = parameters;
56 | }
57 |
58 | @Override
59 | public String getType() {
60 | return visitor;
61 | }
62 |
63 | @Override
64 | public void setType(String visitor) {
65 | this.visitor = visitor;
66 | }
67 |
68 | @Override
69 | public Object getVisitorInstance() {
70 | return visitorInstance;
71 | }
72 |
73 | @Override
74 | public void setVisitorInstance(Object visitorInstance) {
75 | this.visitorInstance = visitorInstance;
76 | }
77 |
78 | @Override
79 | public void isMergeable(boolean isMergeable) {
80 | this.isMergeable = isMergeable;
81 | }
82 |
83 | @Override
84 | public boolean isMergeable() {
85 | return isMergeable;
86 | }
87 |
88 | @Override
89 | public void setMergePolicy(String mergePolicy) {
90 | this.mergePolicy = mergePolicy;
91 | }
92 |
93 | @Override
94 | public String getMergePolicy() {
95 | return mergePolicy;
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/AbstractChainConfigurationProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers;
17 |
18 | import org.walkmod.conf.entities.ChainConfig;
19 | import org.walkmod.conf.entities.ReaderConfig;
20 | import org.walkmod.conf.entities.WalkerConfig;
21 | import org.walkmod.conf.entities.WriterConfig;
22 | import org.walkmod.conf.entities.impl.ParserConfigImpl;
23 | import org.walkmod.conf.entities.impl.WalkerConfigImpl;
24 | import org.walkmod.conf.entities.impl.WriterConfigImpl;
25 |
26 | public class AbstractChainConfigurationProvider {
27 |
28 | public void addDefaultReaderConfig(ChainConfig ac) {
29 | ReaderConfig readerConfig = new ReaderConfig();
30 | readerConfig.setPath(null);
31 | readerConfig.setType(null);
32 | ac.setReaderConfig(readerConfig);
33 | }
34 |
35 | public void addDefaultWalker(ChainConfig ac) {
36 | WalkerConfig wc = new WalkerConfigImpl();
37 | wc.setType(null);
38 | wc.setParserConfig(new ParserConfigImpl());
39 | ac.setWalkerConfig(wc);
40 | }
41 |
42 | public void addDefaultWriterConfig(ChainConfig ac) {
43 | WriterConfig wc = new WriterConfigImpl();
44 | wc.setPath(ac.getReaderConfig().getPath());
45 | wc.setType(null);
46 | ac.setWriterConfig(wc);
47 | }
48 |
49 |
50 |
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/ConfigurationAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers;
17 |
18 | public interface ConfigurationAction {
19 |
20 | public void execute() throws Exception;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/DynamicModulesConfigurationProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers;
17 |
18 | import java.util.List;
19 |
20 | import org.walkmod.conf.ConfigurationException;
21 | import org.walkmod.conf.ConfigurationProvider;
22 | import org.walkmod.conf.DummyConfigurationProvider;
23 | import org.walkmod.conf.entities.Configuration;
24 |
25 | public class DynamicModulesConfigurationProvider implements ConfigurationProvider {
26 |
27 | private Configuration configuration;
28 |
29 |
30 |
31 | public DynamicModulesConfigurationProvider() {
32 |
33 | }
34 |
35 | @Override
36 | public void init(Configuration configuration) {
37 | this.configuration = configuration;
38 |
39 | }
40 |
41 | @Override
42 | public void load() throws ConfigurationException {
43 | DummyConfigurationProvider dummy = new DummyConfigurationProvider();
44 | dummy.init(configuration);
45 | try {
46 | configuration.runInitializers(dummy);
47 | } catch (Exception e) {
48 | throw new ConfigurationException("Error running initializers", e);
49 | }
50 | List modules = configuration.getModules();
51 |
52 | if (modules != null && !modules.isEmpty()) {
53 | configuration.getChainConfigs().clear();
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/ExecutionModeProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers;
17 |
18 | import org.walkmod.conf.ConfigurationException;
19 | import org.walkmod.conf.ConfigurationProvider;
20 | import org.walkmod.conf.ExecutionModeEnum;
21 | import org.walkmod.conf.entities.Configuration;
22 |
23 | public class ExecutionModeProvider implements ConfigurationProvider {
24 |
25 | private ExecutionModeEnum mode;
26 |
27 | private Configuration configuration;
28 |
29 | public ExecutionModeProvider(ExecutionModeEnum mode) {
30 | this.mode = mode;
31 | }
32 |
33 | @Override
34 | public void init(Configuration configuration) {
35 | this.configuration = configuration;
36 | }
37 |
38 | @Override
39 | public void load() throws ConfigurationException {
40 | configuration.setExecutionMode(mode);
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/WritersConfigurationProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers;
17 |
18 | import org.walkmod.conf.ConfigurationException;
19 | import org.walkmod.conf.ConfigurationProvider;
20 | import org.walkmod.conf.ExecutionModeEnum;
21 | import org.walkmod.conf.entities.ChainConfig;
22 | import org.walkmod.conf.entities.Configuration;
23 | import org.walkmod.writers.VisitorMessagesWriter;
24 |
25 | public class WritersConfigurationProvider implements ConfigurationProvider {
26 |
27 | private Configuration configuration;
28 |
29 | @Override
30 | public void init(Configuration configuration) {
31 | this.configuration = configuration;
32 | }
33 |
34 | @Override
35 | public void load() throws ConfigurationException {
36 |
37 | ExecutionModeEnum executionMode = configuration.getExecutionMode();
38 |
39 | if (executionMode.equals(ExecutionModeEnum.PATCH)) {
40 | for (ChainConfig cc : configuration.getChainConfigs()) {
41 | cc.getWriterConfig().setType(cc.getWriterConfig().getPatcherType());
42 | }
43 | } else if (executionMode.equals(ExecutionModeEnum.CHECK)) {
44 | for (ChainConfig cc : configuration.getChainConfigs()) {
45 | cc.getWriterConfig().setType(VisitorMessagesWriter.class.getName());
46 | cc.getWriterConfig().setModelWriter(new VisitorMessagesWriter());
47 | }
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/xml/AddChainXMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.xml;
17 |
18 | import org.w3c.dom.Document;
19 | import org.w3c.dom.Element;
20 | import org.w3c.dom.Node;
21 | import org.w3c.dom.NodeList;
22 | import org.walkmod.conf.ConfigurationProvider;
23 | import org.walkmod.conf.entities.ChainConfig;
24 | import org.walkmod.conf.providers.XMLConfigurationProvider;
25 |
26 | public class AddChainXMLAction extends AbstractXMLConfigurationAction {
27 |
28 | private ChainConfig chainCfg;
29 | private String before;
30 |
31 | public AddChainXMLAction(ChainConfig chainCfg, XMLConfigurationProvider provider, boolean recursive, String before) {
32 | super(provider, recursive);
33 | this.chainCfg = chainCfg;
34 | this.before = before;
35 | }
36 |
37 | @Override
38 | public void doAction() throws Exception {
39 | Document document = provider.getDocument();
40 | Element rootElement = document.getDocumentElement();
41 | NodeList children = rootElement.getChildNodes();
42 | int childSize = children.getLength();
43 | Element beforeElement = null;
44 | if (chainCfg.getName() != null && !"".equals(chainCfg.getName())) {
45 | for (int i = 0; i < childSize; i++) {
46 | Node childNode = children.item(i);
47 | if (childNode instanceof Element) {
48 | Element child = (Element) childNode;
49 | final String nodeName = child.getNodeName();
50 | if ("chain".equals(nodeName)) {
51 | String name = child.getAttribute("name");
52 | if (name.equals(chainCfg.getName())) {
53 | return;
54 | }
55 | else if(before != null && name.equals(before)){
56 | beforeElement = child;
57 | }
58 | }
59 |
60 | }
61 | }
62 | }
63 | if(beforeElement == null){
64 | rootElement.appendChild(createChainElement(chainCfg));
65 | }
66 | else{
67 | rootElement.insertBefore(createChainElement(chainCfg), beforeElement);
68 | }
69 |
70 | provider.persist();
71 |
72 | }
73 |
74 | @Override
75 | public AbstractXMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
76 | return new AddChainXMLAction(chainCfg, (XMLConfigurationProvider) provider, recursive, before);
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/xml/RemoveChainsXMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.xml;
17 |
18 | import java.util.HashSet;
19 | import java.util.List;
20 |
21 | import org.w3c.dom.Document;
22 | import org.w3c.dom.Element;
23 | import org.w3c.dom.Node;
24 | import org.w3c.dom.NodeList;
25 | import org.walkmod.conf.ConfigurationProvider;
26 | import org.walkmod.conf.providers.XMLConfigurationProvider;
27 |
28 | public class RemoveChainsXMLAction extends AbstractXMLConfigurationAction {
29 |
30 | private List chains;
31 |
32 | public RemoveChainsXMLAction(List chains, XMLConfigurationProvider provider, boolean recursive) {
33 | super(provider, recursive);
34 | this.chains = chains;
35 | }
36 |
37 | @Override
38 | public void doAction() throws Exception {
39 | Document document = provider.getDocument();
40 | HashSet aux = new HashSet(chains);
41 |
42 | Element rootElement = document.getDocumentElement();
43 | NodeList children = rootElement.getChildNodes();
44 | int childSize = children.getLength();
45 |
46 | Element child = null;
47 | int removed = 0;
48 | for (int i = 0; i < childSize; i++) {
49 | Node childNode = children.item(i);
50 | if (childNode instanceof Element) {
51 | child = (Element) childNode;
52 | final String nodeName = child.getNodeName();
53 |
54 | if ("chain".equals(nodeName)) {
55 | if (aux.contains(child.getAttribute("name"))) {
56 | rootElement.removeChild(childNode);
57 | removed++;
58 | }
59 | }
60 |
61 | else if ("transformation".equals(nodeName) && aux.contains("default")) {
62 | rootElement.removeChild(childNode);
63 | removed++;
64 | }
65 | }
66 | }
67 |
68 | if (removed > 0) {
69 |
70 | provider.persist();
71 | }
72 |
73 | }
74 |
75 | @Override
76 | public AbstractXMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
77 | return new RemoveChainsXMLAction(chains, (XMLConfigurationProvider) provider, recursive);
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/xml/RemoveModulesXMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.xml;
17 |
18 | import java.util.List;
19 |
20 | import org.w3c.dom.Document;
21 | import org.w3c.dom.Element;
22 | import org.w3c.dom.Node;
23 | import org.w3c.dom.NodeList;
24 | import org.walkmod.conf.ConfigurationProvider;
25 | import org.walkmod.conf.providers.XMLConfigurationProvider;
26 |
27 | public class RemoveModulesXMLAction extends AbstractXMLConfigurationAction {
28 |
29 | private List modules;
30 |
31 | public RemoveModulesXMLAction(List modules, XMLConfigurationProvider provider) {
32 | super(provider, false);
33 | this.modules = modules;
34 | }
35 |
36 | @Override
37 | public void doAction() throws Exception {
38 |
39 | Document document = provider.getDocument();
40 | Element rootElement = document.getDocumentElement();
41 | NodeList children = rootElement.getChildNodes();
42 | int childSize = children.getLength();
43 |
44 | Element child = null;
45 | int removed = 0;
46 | for (int i = 0; i < childSize; i++) {
47 | Node childNode = children.item(i);
48 | if (childNode instanceof Element) {
49 | child = (Element) childNode;
50 | final String nodeName = child.getNodeName();
51 |
52 | if ("modules".equals(nodeName)) {
53 | NodeList moduleNodeList = child.getChildNodes();
54 | int max = moduleNodeList.getLength();
55 | for (int j = 0; j < max; j++) {
56 | String value = moduleNodeList.item(j).getTextContent().trim();
57 | if (modules.contains(value)) {
58 | child.removeChild(moduleNodeList.item(j));
59 | removed++;
60 | }
61 | }
62 | if (removed == max) {
63 | rootElement.removeChild(child);
64 | }
65 | }
66 | }
67 | }
68 |
69 | if (removed > 0) {
70 | provider.persist();
71 | }
72 |
73 | }
74 |
75 | @Override
76 | public AbstractXMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
77 |
78 | return new RemoveModulesXMLAction(modules, (XMLConfigurationProvider) provider);
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/yml/AddModulesYMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.yml;
17 |
18 | import java.util.HashSet;
19 | import java.util.Iterator;
20 | import java.util.List;
21 |
22 | import org.walkmod.conf.ConfigurationProvider;
23 | import org.walkmod.conf.providers.YAMLConfigurationProvider;
24 |
25 | import com.fasterxml.jackson.databind.JsonNode;
26 | import com.fasterxml.jackson.databind.node.ArrayNode;
27 | import com.fasterxml.jackson.databind.node.ObjectNode;
28 | import com.fasterxml.jackson.databind.node.TextNode;
29 |
30 | public class AddModulesYMLAction extends AbstractYMLConfigurationAction {
31 |
32 | private List modules;
33 |
34 | public AddModulesYMLAction(List modules, YAMLConfigurationProvider provider) {
35 | super(provider, false);
36 | this.modules = modules;
37 | }
38 |
39 | @Override
40 | public void doAction(JsonNode node) throws Exception {
41 | ArrayNode aux = null;
42 | HashSet modulesToAdd = new HashSet(modules);
43 | if (node.has("modules")) {
44 | JsonNode list = node.get("modules");
45 | Iterator it = list.iterator();
46 |
47 | while (it.hasNext()) {
48 | JsonNode next = it.next();
49 | modulesToAdd.remove(next.asText().trim());
50 |
51 | }
52 | if (!modulesToAdd.isEmpty()) {
53 | if (list.isArray()) {
54 | aux = (ArrayNode) list;
55 | }
56 | }
57 | } else {
58 | aux = new ArrayNode(provider.getObjectMapper().getNodeFactory());
59 | }
60 | if (!modulesToAdd.isEmpty()) {
61 | for (String moduleToAdd : modulesToAdd) {
62 | TextNode prov = new TextNode(moduleToAdd);
63 | aux.add(prov);
64 | }
65 | ObjectNode auxNode = (ObjectNode) node;
66 | auxNode.set("modules", aux);
67 | provider.write(node);
68 | }
69 |
70 | }
71 |
72 | @Override
73 | public AbstractYMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
74 |
75 | return new AddModulesYMLAction(modules, (YAMLConfigurationProvider) provider);
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/yml/RemoveModulesYMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.yml;
17 |
18 | import java.util.Iterator;
19 | import java.util.List;
20 |
21 | import org.walkmod.conf.ConfigurationProvider;
22 | import org.walkmod.conf.providers.YAMLConfigurationProvider;
23 |
24 | import com.fasterxml.jackson.databind.JsonNode;
25 | import com.fasterxml.jackson.databind.ObjectMapper;
26 | import com.fasterxml.jackson.databind.node.ArrayNode;
27 | import com.fasterxml.jackson.databind.node.ObjectNode;
28 |
29 | public class RemoveModulesYMLAction extends AbstractYMLConfigurationAction {
30 |
31 | private List modules;
32 |
33 | public RemoveModulesYMLAction(List modules, YAMLConfigurationProvider provider) {
34 | super(provider, false);
35 | this.modules = modules;
36 | }
37 |
38 | @Override
39 | public void doAction(JsonNode node) throws Exception {
40 | if (node.has("modules")) {
41 | JsonNode aux = node.get("modules");
42 | ObjectMapper mapper = provider.getObjectMapper();
43 | if (aux.isArray()) {
44 | ArrayNode modulesList = (ArrayNode) node.get("modules");
45 | Iterator it = modulesList.iterator();
46 | ArrayNode newModulesList = new ArrayNode(mapper.getNodeFactory());
47 | while (it.hasNext()) {
48 | JsonNode next = it.next();
49 | if (next.isTextual()) {
50 | String text = next.asText();
51 | if (!modules.contains(text)) {
52 | newModulesList.add(text);
53 | }
54 | }
55 | }
56 | ObjectNode oNode = (ObjectNode) node;
57 | if (newModulesList.size() > 0) {
58 | oNode.set("modules", newModulesList);
59 | } else {
60 | oNode.remove("modules");
61 | }
62 | provider.write(node);
63 | }
64 | }
65 | }
66 |
67 | @Override
68 | public AbstractYMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
69 | return new RemoveModulesYMLAction(modules, (YAMLConfigurationProvider) provider);
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/conf/providers/yml/RemovePluginYMLAction.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.conf.providers.yml;
17 |
18 | import java.util.Iterator;
19 |
20 | import javax.xml.transform.TransformerException;
21 |
22 | import org.walkmod.conf.ConfigurationProvider;
23 | import org.walkmod.conf.entities.PluginConfig;
24 | import org.walkmod.conf.providers.YAMLConfigurationProvider;
25 |
26 | import com.fasterxml.jackson.databind.JsonNode;
27 | import com.fasterxml.jackson.databind.node.ArrayNode;
28 |
29 | public class RemovePluginYMLAction extends AbstractYMLConfigurationAction {
30 |
31 | private PluginConfig pluginConfig;
32 |
33 | public RemovePluginYMLAction(PluginConfig pluginConfig, YAMLConfigurationProvider provider, boolean recursive) {
34 | super(provider, recursive);
35 | this.pluginConfig = pluginConfig;
36 | }
37 |
38 | @Override
39 | public void doAction(JsonNode node) throws Exception {
40 | if (node.has("plugins")) {
41 | ArrayNode pluginList = null;
42 | JsonNode aux = node.get("plugins");
43 | if (aux.isArray()) {
44 | pluginList = (ArrayNode) node.get("plugins");
45 | Iterator it = pluginList.iterator();
46 |
47 | int index = -1;
48 | int i = 0;
49 | while (it.hasNext() && index == -1) {
50 | JsonNode next = it.next();
51 | if (next.isTextual()) {
52 | String text = next.asText();
53 | String[] parts = text.split(":");
54 | if (parts.length >= 2) {
55 | if (parts[0].equals(pluginConfig.getGroupId())
56 | && parts[1].equals(pluginConfig.getArtifactId())) {
57 | index = i;
58 | }
59 | }
60 | }
61 | i++;
62 | }
63 | if (index > -1) {
64 | pluginList.remove(index);
65 | }
66 |
67 | } else {
68 | throw new TransformerException("The plugins element is not a valid array");
69 | }
70 | }
71 |
72 | provider.write(node);
73 |
74 | }
75 |
76 | @Override
77 | public AbstractYMLConfigurationAction clone(ConfigurationProvider provider, boolean recursive) {
78 |
79 | return new RemovePluginYMLAction(pluginConfig, (YAMLConfigurationProvider) provider, recursive);
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/exceptions/InvalidConfigurationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.exceptions;
17 |
18 | @SuppressWarnings("serial")
19 | public class InvalidConfigurationException extends Exception {
20 |
21 | public InvalidConfigurationException(Throwable cause) {
22 | super(cause);
23 | if (cause != null) {
24 | this.setStackTrace(cause.getStackTrace());
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/exceptions/InvalidImportException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.exceptions;
17 |
18 | public class InvalidImportException extends IllegalArgumentException {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/exceptions/InvalidTransformationRuleException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.exceptions;
17 |
18 | public class InvalidTransformationRuleException extends Exception {
19 |
20 | public InvalidTransformationRuleException() {
21 | super();
22 | }
23 |
24 | public InvalidTransformationRuleException(String msg, Throwable cause) {
25 | super(msg, cause);
26 | }
27 |
28 | public InvalidTransformationRuleException(String msg) {
29 | super(msg);
30 | }
31 |
32 | public InvalidTransformationRuleException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/impl/DefaultChainAdapterFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.impl;
17 |
18 | import java.util.Collection;
19 | import java.util.Iterator;
20 |
21 | import org.apache.commons.logging.Log;
22 | import org.apache.commons.logging.LogFactory;
23 | import org.walkmod.ChainAdapter;
24 | import org.walkmod.ChainAdapterFactory;
25 | import org.walkmod.conf.entities.ChainConfig;
26 | import org.walkmod.conf.entities.Configuration;
27 |
28 | public class DefaultChainAdapterFactory implements ChainAdapterFactory {
29 |
30 | private static final Log LOG = LogFactory.getLog(DefaultChainAdapterFactory.class);
31 |
32 | @Override
33 | public ChainAdapter createChainProxy(Configuration configuration, String chain) {
34 |
35 | Collection acs = configuration.getChainConfigs();
36 | if (acs != null) {
37 | Iterator it = acs.iterator();
38 | boolean end = false;
39 | ChainConfig acfg = null;
40 | while (it.hasNext() && !end) {
41 | acfg = it.next();
42 | end = chain.equals(acfg.getName());
43 | }
44 | if (end) {
45 | LOG.debug("Chain " + chain + " found");
46 | ChainAdapter ap = new DefaultChainAdapter();
47 | ap.setChainConfig(acfg);
48 | ap.setChainInvocation(new DefaultChainInvocation());
49 | ap.prepare();
50 | return ap;
51 | }
52 | }
53 | return null;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/impl/DefaultChainInvocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.impl;
17 |
18 | import org.walkmod.ChainAdapter;
19 | import org.walkmod.ChainInvocation;
20 | import org.walkmod.ChainWalkerAdapter;
21 | import org.walkmod.ChainWalkerInvocation;
22 | import org.walkmod.exceptions.WalkModException;
23 |
24 | public class DefaultChainInvocation implements ChainInvocation {
25 |
26 | private ChainAdapter chainAdapter;
27 |
28 | @Override
29 | public void init(ChainAdapter chainAdapter) {
30 | this.chainAdapter = chainAdapter;
31 | }
32 |
33 | @Override
34 | public void invoke() throws WalkModException {
35 | ChainWalkerAdapter wa = chainAdapter.getWalkerAdapter();
36 | ChainWalkerInvocation wi = new DefaultChainWalkerInvocation();
37 | wi.init(wa);
38 | wi.invoke();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/impl/DefaultChainWalkerInvocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.impl;
17 |
18 | import org.apache.commons.logging.Log;
19 | import org.apache.commons.logging.LogFactory;
20 | import org.walkmod.ChainWalker;
21 | import org.walkmod.ChainWalkerAdapter;
22 | import org.walkmod.ChainWalkerInvocation;
23 | import org.walkmod.exceptions.WalkModException;
24 |
25 | public class DefaultChainWalkerInvocation implements ChainWalkerInvocation {
26 |
27 | private ChainWalkerAdapter walkerAdapter;
28 |
29 | private static final Log LOG = LogFactory.getLog(DefaultChainWalkerInvocation.class);
30 |
31 | @Override
32 | public void init(ChainWalkerAdapter transformation) {
33 | this.walkerAdapter = transformation;
34 | }
35 |
36 | @Override
37 | public void invoke() throws WalkModException {
38 | ChainWalker walker = walkerAdapter.getWalker();
39 | if (walker != null) {
40 | try {
41 | walker.execute();
42 | } catch (Exception e) {
43 | throw new WalkModException("An exeception has been produced during the " + walkerAdapter.getName()
44 | + " transformation", e);
45 | }
46 | }
47 | LOG.debug("The transformation [" + walkerAdapter.getName() + "] has been executed");
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/patches/JsonPatchFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.patches;
17 |
18 | import java.util.List;
19 |
20 | import com.alibaba.fastjson.JSONObject;
21 | import com.fasterxml.jackson.core.JsonProcessingException;
22 | import com.fasterxml.jackson.databind.ObjectMapper;
23 |
24 | public class JsonPatchFormatter implements PatchFormatter {
25 | private ObjectMapper mapper = new ObjectMapper();
26 |
27 | @Override
28 | public String format(Patch patch) {
29 |
30 | try {
31 | return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(patch);
32 | } catch (JsonProcessingException e) {
33 | throw new RuntimeException(e);
34 | }
35 |
36 | }
37 |
38 | @Override
39 | public String format(String location, List patches) {
40 | JSONObject object = new JSONObject();
41 | object.put("file", location);
42 | object.put("patches", patches);
43 | try {
44 | return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
45 | } catch (JsonProcessingException e) {
46 | throw new RuntimeException(e);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/patches/PatchFormat.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.patches;
17 |
18 | public enum PatchFormat {
19 |
20 | JSON("json", new JsonPatchFormatter()), RAW("raw", new RawPatchFormatter());
21 |
22 | private final String name;
23 |
24 | private final PatchFormatter formatter;
25 |
26 | private PatchFormat(String s, PatchFormatter f) {
27 | name = s;
28 | formatter = f;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return name;
34 | }
35 |
36 | public PatchFormatter getFormatter() {
37 | return formatter;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/patches/PatchFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.patches;
17 |
18 | import java.util.List;
19 |
20 | public interface PatchFormatter {
21 |
22 | public String format(Patch patch);
23 |
24 | public String format(String location, List patches);
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/patches/Patches.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.patches;
17 |
18 | import java.io.File;
19 | import java.util.Arrays;
20 | import java.util.Iterator;
21 | import java.util.List;
22 |
23 | import difflib.DiffUtils;
24 | import difflib.Patch;
25 | import difflib.PatchFailedException;
26 |
27 | public class Patches {
28 |
29 | public static String generatePatch(String originalText, String text, String location) {
30 | List original = Arrays.asList(originalText.split("\n"));
31 | List revised = Arrays.asList(text.split("\n"));
32 |
33 | Patch patches = DiffUtils.diff(original, revised);
34 | List unifiedDiffs = DiffUtils.generateUnifiedDiff("a" + File.separator + location, "b" + File.separator
35 | + location, original, patches, 4);
36 | Iterator it = unifiedDiffs.iterator();
37 |
38 | StringBuffer sb = new StringBuffer();
39 | while (it.hasNext()) {
40 | sb.append(it.next());
41 | if (it.hasNext()) {
42 | sb.append('\n');
43 | }
44 | }
45 | return sb.toString();
46 | }
47 |
48 | public static String applyPatch(String text, String patch) throws PatchFailedException {
49 | List original = Arrays.asList(text.split("\n"));
50 | List diff = Arrays.asList(patch.split("\n"));
51 |
52 | Patch generatedPatch = DiffUtils.parseUnifiedDiff(diff);
53 | Iterator it = DiffUtils.patch(original, generatedPatch).iterator();
54 | StringBuffer sb = new StringBuffer();
55 | while (it.hasNext()) {
56 | sb.append(it.next());
57 | if (it.hasNext()) {
58 | sb.append('\n');
59 | }
60 | }
61 | return sb.toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/patches/RawPatchFormatter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.patches;
17 |
18 | import java.util.List;
19 |
20 | public class RawPatchFormatter implements PatchFormatter {
21 |
22 | @Override
23 | public String format(Patch patch) {
24 | return patch.getDiff();
25 | }
26 |
27 | @Override
28 | public String format(String location, List patches) {
29 | StringBuffer sb = new StringBuffer();
30 | for (Patch patch : patches) {
31 | sb.append(format(patch));
32 | sb.append("\n");
33 | }
34 | return sb.toString();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/query/QueryEngine.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.query;
17 |
18 | import java.util.Map;
19 |
20 | import org.walkmod.walkers.VisitorContext;
21 |
22 | public interface QueryEngine {
23 |
24 | public void initialize(VisitorContext context);
25 |
26 | public void initialize(VisitorContext context, Map parameters);
27 |
28 | public Object resolve(String query);
29 |
30 | public Object resolve(Object context, String query);
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/query/QueryEngineAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.query;
17 |
18 | public interface QueryEngineAware {
19 |
20 | public void setQueryEngine(QueryEngine queryEngine);
21 |
22 | public QueryEngine getQueryEngine();
23 |
24 | public Object query(String query);
25 |
26 | public Object query(Object context, String query);
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/readers/DefaultFileReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.readers;
17 |
18 | import java.io.File;
19 |
20 | import org.walkmod.ChainReader;
21 | import org.walkmod.Resource;
22 | import org.walkmod.util.FileResource;
23 |
24 | public class DefaultFileReader extends ChainReader {
25 |
26 | private String[] extensions;
27 |
28 | public String[] getExtensions() {
29 | return extensions;
30 | }
31 |
32 | public void setExtensions(String[] extensions) {
33 | this.extensions = extensions;
34 | }
35 |
36 | @Override
37 | public Resource read() throws Exception {
38 | FileResource resource = new FileResource();
39 | resource.setPath(getPath());
40 | resource.setExtensions(getExtensions());
41 | resource.setExcludes(getExcludes());
42 | resource.setIncludes(getIncludes());
43 | return resource;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/templates/TemplateEngine.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.templates;
17 |
18 | import java.io.File;
19 |
20 | import org.walkmod.walkers.VisitorContext;
21 |
22 | public interface TemplateEngine {
23 |
24 | public void initialize(VisitorContext context, Object rootNode);
25 |
26 | public String applyTemplate(File template);
27 |
28 | public String applyTemplate(File template, File properties);
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/templates/TemplatesAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.templates;
17 |
18 | import java.util.List;
19 |
20 | public interface TemplatesAware {
21 |
22 | public List getTemplates();
23 |
24 | public void setTemplates(List templates);
25 |
26 | public void setTemplateEngine(TemplateEngine templateEngine);
27 |
28 | public TemplateEngine getTemplateEngine();
29 |
30 | public String getRootLabel();
31 |
32 | public void setRootLabel(String rootLabel);
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/util/location/Locatable.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.util.location;
17 |
18 | public interface Locatable {
19 |
20 | public Location getLocation();
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/util/location/Location.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.util.location;
17 |
18 | import java.util.List;
19 |
20 | public interface Location {
21 |
22 | /**
23 | * Get the description of this location
24 | *
25 | * @return the description (can be null
)
26 | */
27 | public String getDescription();
28 |
29 | /**
30 | * Get the URI of this location
31 | *
32 | * @return the URI (null
if unknown).
33 | */
34 | public String getURI();
35 |
36 | /**
37 | * Get the line number of this location
38 | *
39 | * @return the line number (-1
if unknown)
40 | */
41 | public int getLineNumber();
42 |
43 | /**
44 | * Get the column number of this location
45 | *
46 | * @return the column number (-1
if unknown)
47 | */
48 | public int getColumnNumber();
49 |
50 | /**
51 | * Gets a source code snippet with the default padding
52 | *
53 | * @param padding
54 | * padding The amount of lines before and after the error to
55 | * include
56 | * @return A list of source lines
57 | */
58 | public List getSnippet(int padding);
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/util/location/LocationImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.util.location;
17 |
18 | import java.io.BufferedReader;
19 | import java.io.InputStream;
20 | import java.io.InputStreamReader;
21 | import java.net.URL;
22 | import java.util.ArrayList;
23 | import java.util.List;
24 |
25 | public class LocationImpl implements Location {
26 |
27 | private final String description;
28 |
29 | private final String URI;
30 |
31 | private final int lineNumber;
32 |
33 | private final int columnNumber;
34 |
35 | public static final LocationImpl UNKNOWN = new LocationImpl(null, null, -1, -1);
36 |
37 | public LocationImpl(String description, String uri) {
38 | this(description, uri, -1, -1);
39 | }
40 |
41 | public LocationImpl(String description, String uri, int line, int column) {
42 | if (uri == null || uri.length() == 0) {
43 | this.URI = null;
44 | this.lineNumber = -1;
45 | this.columnNumber = -1;
46 | } else {
47 | this.URI = uri;
48 | this.lineNumber = line;
49 | this.columnNumber = column;
50 | }
51 | if (description != null && description.length() == 0) {
52 | description = null;
53 | }
54 | this.description = description;
55 | }
56 |
57 | public String getDescription() {
58 | return description;
59 | }
60 |
61 | public String getURI() {
62 | return URI;
63 | }
64 |
65 | public int getLineNumber() {
66 | return lineNumber;
67 | }
68 |
69 | public int getColumnNumber() {
70 | return columnNumber;
71 | }
72 |
73 | public List getSnippet(int padding) {
74 | List snippet = new ArrayList();
75 | if (getLineNumber() > 0) {
76 | try {
77 | InputStream in = new URL(getURI()).openStream();
78 | BufferedReader reader = new BufferedReader(new InputStreamReader(in));
79 | int lineno = 0;
80 | int errno = getLineNumber();
81 | String line;
82 | while ((line = reader.readLine()) != null) {
83 | lineno++;
84 | if (lineno >= errno - padding && lineno <= errno + padding) {
85 | snippet.add(line);
86 | }
87 | }
88 | } catch (Exception ex) {
89 | }
90 | }
91 | return snippet;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/walkers/ParseException.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.walkers;
17 |
18 | public class ParseException extends Exception {
19 |
20 | public ParseException() {
21 | super();
22 | }
23 |
24 | public ParseException(String msg, Throwable cause) {
25 | super(msg, cause);
26 | }
27 |
28 | public ParseException(Throwable cause) {
29 | super(cause);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/walkers/Parser.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.walkers;
17 |
18 | import java.io.File;
19 | import java.io.Reader;
20 |
21 | public interface Parser {
22 |
23 | public T parse(String text) throws ParseException;
24 |
25 | public T parse(String text, boolean withoutLocation) throws ParseException;
26 |
27 | public T parse(File file) throws ParseException;
28 |
29 | public T parse(File file, String encoding) throws ParseException;
30 |
31 | public T parse(Reader reader) throws ParseException;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/walkers/ParserAware.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.walkers;
17 |
18 | public interface ParserAware {
19 |
20 | public void setParser(Parser> parser);
21 |
22 | public Parser> getParser();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/walkers/VisitorMessage.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.walkers;
17 |
18 | public class VisitorMessage {
19 |
20 | private String location;
21 |
22 | private String type;
23 |
24 | private String text;
25 |
26 | public VisitorMessage() {
27 | }
28 |
29 | public VisitorMessage(String location, String type, String text) {
30 | this.location = location;
31 | this.type = type;
32 | this.text = text;
33 | }
34 |
35 | public VisitorMessage(String location, String text) {
36 | this.location = location;
37 | this.type = "GitMessage";
38 | this.text = text;
39 | }
40 |
41 | public String getType() {
42 | return type;
43 | }
44 |
45 | public void setType(String type) {
46 | this.type = type;
47 | }
48 |
49 | public String getText() {
50 | return text;
51 | }
52 |
53 | public void setText(String text) {
54 | this.text = text;
55 | }
56 |
57 | public String getLocation() {
58 | return location;
59 | }
60 |
61 | public void setLocation(String location) {
62 | this.location = location;
63 | }
64 |
65 | @Override
66 | public String toString() {
67 | return location + " : " + text;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/writers/AbstractPatchWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.writers;
17 |
18 | import java.io.BufferedWriter;
19 | import java.io.File;
20 | import java.io.FileOutputStream;
21 | import java.io.OutputStreamWriter;
22 | import java.io.Writer;
23 |
24 | import org.walkmod.walkers.VisitorContext;
25 |
26 | public abstract class AbstractPatchWriter extends AbstractFileWriter {
27 |
28 | private boolean patchPerChange = true;
29 |
30 | private boolean patchPerFile = true;
31 |
32 | private String patchFormat = "json";
33 |
34 | private String cause = "walkmod";
35 |
36 | @Override
37 | public File createOutputDirectory(Object o) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public boolean requiresToAppend(VisitorContext vc) {
43 | return true;
44 | }
45 |
46 | @Override
47 | protected Writer getWriter(File out) throws Exception {
48 | return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("walkmod.patch").getCanonicalFile(), true), getEncoding()));
49 | }
50 |
51 | public void setPatchPerChange(boolean patchPerChange) {
52 | this.patchPerChange = patchPerChange;
53 | }
54 |
55 | public void setPatchPerFile(boolean patchPerFile) {
56 | this.patchPerFile = patchPerFile;
57 | }
58 |
59 | public void setPatchFormat(String format) {
60 | this.patchFormat = format;
61 | }
62 |
63 | public String getCause() {
64 | return cause;
65 | }
66 |
67 | public void setCause(String cause) {
68 | this.cause = cause;
69 | }
70 |
71 | public boolean isPatchPerChange() {
72 | return patchPerChange;
73 | }
74 |
75 | public boolean isPatchPerFile() {
76 | return patchPerFile;
77 | }
78 |
79 | public String getPatchFormat() {
80 | return patchFormat;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/writers/StringWriter.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.writers;
17 |
18 | import java.io.File;
19 |
20 | import org.walkmod.walkers.VisitorContext;
21 |
22 | public class StringWriter extends AbstractFileWriter {
23 |
24 | @Override
25 | public String getContent(Object n, VisitorContext vc) {
26 | return n.toString();
27 | }
28 |
29 | @Override
30 | public File createOutputDirectory(Object o) {
31 | return null;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/walkmod/writers/Summary.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .*/
16 | package org.walkmod.writers;
17 |
18 | import java.io.File;
19 | import java.util.LinkedList;
20 | import java.util.List;
21 |
22 | public class Summary {
23 |
24 | private static Summary instance = null;
25 |
26 | private List writtenFiles;
27 |
28 | private Summary() {
29 | writtenFiles = new LinkedList();
30 | }
31 |
32 | public static Summary getInstance() {
33 | if (instance == null) {
34 | instance = new Summary();
35 | }
36 | return instance;
37 | }
38 |
39 | public void clear() {
40 | writtenFiles.clear();
41 | }
42 |
43 | public List getWrittenFiles() {
44 | return writtenFiles;
45 | }
46 |
47 | public void addFile(File file) {
48 | writtenFiles.add(file);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/license-header.txt:
--------------------------------------------------------------------------------
1 |
2 | Copyright (C) 2013 Raquel Pau and Albert Coroleu.
3 |
4 | Walkmod is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU Lesser General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Walkmod is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU Lesser General Public License for more details.
13 |
14 | You should have received a copy of the GNU Lesser General Public License
15 | along with Walkmod. If not, see .
--------------------------------------------------------------------------------
/src/main/resources/walkmod-1.0.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/src/main/resources/walkmod-1.1.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/main/resources/walkmod-lang-1.0.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/resources/walkmod-plugins-1.0.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/AbstractWalkmodExecutionTest.java:
--------------------------------------------------------------------------------
1 | package org.walkmod;
2 |
3 | import java.io.BufferedOutputStream;
4 | import java.io.ByteArrayOutputStream;
5 | import java.io.PrintStream;
6 |
7 | import org.apache.log4j.ConsoleAppender;
8 | import org.apache.log4j.Logger;
9 | import org.apache.log4j.PatternLayout;
10 | import org.walkmod.conf.entities.impl.ConfigurationImpl;
11 |
12 | public abstract class AbstractWalkmodExecutionTest {
13 | public String run(String[] args) throws Exception {
14 |
15 | ByteArrayOutputStream mem = new ByteArrayOutputStream();
16 | BufferedOutputStream stream = new BufferedOutputStream(mem);
17 |
18 | PrintStream ps = new PrintStream(stream);
19 | PrintStream old = System.out;
20 | System.setOut(ps);
21 |
22 | WalkModFacade.log = Logger.getLogger(WalkModFacade.class.getName());
23 | WalkModFacade.log.removeAllAppenders();
24 |
25 | ConfigurationImpl.log = Logger.getLogger(ConfigurationImpl.class.getName());
26 | ConfigurationImpl.log.removeAllAppenders();
27 |
28 | ConsoleAppender appender = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
29 | appender.setName("stdout");
30 | WalkModFacade.log.addAppender(appender);
31 | ConfigurationImpl.log.addAppender(appender);
32 |
33 | String result = "";
34 | try {
35 | WalkModDispatcher.main(args);
36 | stream.flush();
37 | result = mem.toString();
38 |
39 | } finally {
40 | System.setOut(old);
41 | ps.close();
42 | stream.close();
43 | mem.close();
44 | }
45 |
46 | return result;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/ScriptEngineExecutionTest.java:
--------------------------------------------------------------------------------
1 | package org.walkmod;
2 |
3 | import java.io.File;
4 |
5 | import org.apache.commons.io.FileUtils;
6 | import org.junit.Assert;
7 | import org.junit.Test;
8 |
9 | public class ScriptEngineExecutionTest extends AbstractWalkmodExecutionTest {
10 |
11 | @Test
12 | public void testScriptExample() throws Exception {
13 | File tmp = new File("src/test/resources/scripts").getAbsoluteFile();
14 | String code = "public class Foo { public String bar; }";
15 | File srcDir = new File(tmp, "src/main/java");
16 | srcDir.mkdirs();
17 | FileUtils.write(new File(srcDir, "Foo.java"), code);
18 |
19 | String userDir = new File(System.getProperty("user.dir")).getAbsolutePath();
20 | System.setProperty("user.dir", tmp.getAbsolutePath());
21 |
22 | try {
23 | run(new String[] { "apply"});
24 | } finally {
25 | System.setProperty("user.dir", userDir);
26 | }
27 | String newContent = FileUtils.readFileToString(new File(srcDir, "Foo.java"));
28 | Assert.assertTrue(newContent.contains("private String"));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/conf/providers/LanguageConfigurationProviderTest.java:
--------------------------------------------------------------------------------
1 | package org.walkmod.conf.providers;
2 |
3 | import java.util.Collection;
4 | import java.util.LinkedList;
5 | import java.util.List;
6 | import java.util.Map;
7 | import org.junit.Assert;
8 | import org.junit.Test;
9 | import org.walkmod.conf.entities.ChainConfig;
10 | import org.walkmod.conf.entities.Configuration;
11 | import org.walkmod.conf.entities.MergePolicyConfig;
12 | import org.walkmod.conf.entities.ReaderConfig;
13 | import org.walkmod.conf.entities.TransformationConfig;
14 | import org.walkmod.conf.entities.WalkerConfig;
15 | import org.walkmod.conf.entities.WriterConfig;
16 | import org.walkmod.conf.entities.impl.ChainConfigImpl;
17 | import org.walkmod.conf.entities.impl.ConfigurationImpl;
18 | import org.walkmod.conf.entities.impl.ParserConfigImpl;
19 | import org.walkmod.conf.entities.impl.TransformationConfigImpl;
20 | import org.walkmod.conf.entities.impl.WalkerConfigImpl;
21 | import org.walkmod.conf.entities.impl.WriterConfigImpl;
22 |
23 | public class LanguageConfigurationProviderTest {
24 |
25 | @Test
26 | public void testNullOverwriting() {
27 | LanguageConfigurationProvider provider = new LanguageConfigurationProvider();
28 | Configuration conf = new ConfigurationImpl();
29 | ChainConfig cc = new ChainConfigImpl();
30 | cc.setName("test-chain");
31 | ReaderConfig reader = new ReaderConfig();
32 | WalkerConfig walker = new WalkerConfigImpl();
33 | TransformationConfig transformation = new TransformationConfigImpl();
34 | transformation.isMergeable(true);
35 | List transf = new LinkedList();
36 | transf.add(transformation);
37 | walker.setParserConfig(new ParserConfigImpl());
38 | walker.setTransformations(transf);
39 | WriterConfig writer = new WriterConfigImpl();
40 | cc.setReaderConfig(reader);
41 | cc.setWalkerConfig(walker);
42 | cc.setWriterConfig(writer);
43 | conf.addChainConfig(cc);
44 | provider.init(conf);
45 | provider.load();
46 | Assert.assertNotNull(reader.getPath());
47 | Assert.assertNotNull(reader.getType());
48 | Assert.assertNotNull(walker.getType());
49 | Assert.assertNotNull(walker.getParserConfig().getType());
50 | Assert.assertNotNull(writer.getPath());
51 | Assert.assertNotNull(writer.getType());
52 | Assert.assertNotNull(transformation.getMergePolicy());
53 | Assert.assertNotNull(conf.getMergePolicies());
54 | Collection mergec = conf.getMergePolicies();
55 | Assert.assertEquals(1, mergec.size());
56 | MergePolicyConfig mpc = mergec.iterator().next();
57 | Assert.assertNotNull(mpc.getDefaultObjectPolicy());
58 | Assert.assertNotNull(mpc.getDefaultTypePolicy());
59 | Map entries = mpc.getPolicyEntries();
60 | Assert.assertEquals(2, entries.size());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/conf/providers/PluginsConfigurationProviderTest.java:
--------------------------------------------------------------------------------
1 | package org.walkmod.conf.providers;
2 |
3 | import java.util.Collection;
4 | import java.util.LinkedList;
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 | import org.walkmod.conf.ConfigurationException;
8 | import org.walkmod.conf.entities.Configuration;
9 | import org.walkmod.conf.entities.PluginConfig;
10 | import org.walkmod.conf.entities.impl.ConfigurationImpl;
11 | import org.walkmod.conf.entities.impl.PluginConfigImpl;
12 |
13 | public class PluginsConfigurationProviderTest {
14 |
15 | @Test
16 | public void testNullOverwriting() {
17 | PluginsConfigurationProvider provider = new PluginsConfigurationProvider();
18 | Configuration conf = new ConfigurationImpl();
19 | provider.init(conf);
20 | provider.load();
21 | Collection plugins = conf.getPlugins();
22 | Assert.assertNotNull(plugins);
23 | Assert.assertEquals(1, plugins.size());
24 | }
25 |
26 | @Test
27 | public void testInvalidPlugins() {
28 | IvyConfigurationProvider provider = new IvyConfigurationProvider();
29 | Configuration conf = new ConfigurationImpl();
30 | provider.init(conf);
31 | PluginConfig pc = new PluginConfigImpl();
32 | pc.setGroupId("foo");
33 | pc.setArtifactId("bar");
34 | pc.setVersion("10");
35 | conf.setPlugins(new LinkedList());
36 | conf.getPlugins().add(pc);
37 | Exception exception = null;
38 | try {
39 | provider.load();
40 | } catch (ConfigurationException e) {
41 | exception = e;
42 | }
43 | Assert.assertNotNull(exception);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/utils/TestUtils.java:
--------------------------------------------------------------------------------
1 | package org.walkmod.utils;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.walkmod.WalkModFacade;
5 | import sun.swing.StringUIClientPropertyKey;
6 |
7 | import java.lang.reflect.Field;
8 |
9 | /**
10 | * Common methods for testing
11 | */
12 | public class TestUtils {
13 |
14 | public static final String FILE_SEPARATOR = System.getProperty("file.separator");
15 | public static final String LINE_SEPARATOR = System.getProperty("line.separator");
16 | public static final String OS_NAME = System.getProperty("os.name");
17 |
18 | /**
19 | * Tells if the test is running on Windows
20 | *
21 | * @return true if Windows, false if a real OS
22 | */
23 | public static boolean isWindows () {
24 | // Use capital name for Win8+
25 | return OS_NAME.startsWith("windows") || OS_NAME.startsWith("Windows");
26 | }
27 |
28 |
29 | /**
30 | * Inspects and object to obtain the the value of a property.
31 | * Provides a method to access private properties with no accessor.
32 | *
33 | * @param instance instance of an object to inspect
34 | * @param propertyName name of the property to inspect
35 | * @param expectedType type of the inspected property
36 | *
37 | * @return The value of the property
38 | */
39 | public static T getValue(Object instance, String propertyName, Class expectedType) {
40 | Class facade = (Class) instance.getClass();
41 | try {
42 | Field field = facade.getDeclaredField(propertyName);
43 | if (!field.isAccessible())
44 | field.setAccessible(true);
45 | return (T)field.get(instance);
46 | } catch (NoSuchFieldException e) {
47 | throw new RuntimeException(e);
48 | } catch (IllegalAccessException e) {
49 | throw new RuntimeException(e);
50 | }
51 | }
52 |
53 | /**
54 | * Builds a path taking into consideration the particularities of the host
55 | * OS (e.g. uses System.getProperty("file.separator")).
56 | *
57 | * @param components list of elements that constitute the path
58 | *
59 | * @return An OS dependant path
60 | */
61 | public static String buildPath(String... components) {
62 | return StringUtils.join(components, FILE_SEPARATOR);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/test/java/org/walkmod/writers/AbstractFileWriterTest.java:
--------------------------------------------------------------------------------
1 | package org.walkmod.writers;
2 |
3 | import java.io.File;
4 | import java.io.FileReader;
5 | import java.io.FileWriter;
6 | import java.io.IOException;
7 | import org.junit.Assert;
8 | import org.junit.Test;
9 | import org.walkmod.walkers.VisitorContext;
10 |
11 | public class AbstractFileWriterTest {
12 |
13 | AbstractFileWriter writer = new AbstractFileWriter() {
14 |
15 | @Override
16 | public File createOutputDirectory(Object o) {
17 | // TODO Auto-generated method stub
18 | return null;
19 | }
20 |
21 | @Override
22 | public String getContent(Object n, VisitorContext vc) {
23 | // TODO Auto-generated method stub
24 | return null;
25 | }
26 | };
27 |
28 | @Test
29 | public void testEndLineChar() throws IOException {
30 | File fileWithCR = File.createTempFile("test", "withCR.txt");
31 | FileWriter fw = new FileWriter(fileWithCR);
32 | fw.write("\r\n");
33 | fw.close();
34 | File fileWithoutCR = File.createTempFile("test", "withoutCR.txt");
35 | fw = new FileWriter(fileWithoutCR);
36 | fw.write("test\n");
37 | fw.close();
38 | char endLine = writer.getEndLineChar(fileWithoutCR);
39 | Assert.assertEquals('\n', endLine);
40 | endLine = writer.getEndLineChar(fileWithCR);
41 | Assert.assertEquals('\r', endLine);
42 | File nonExistent = new File("test");
43 | endLine = writer.getEndLineChar(nonExistent);
44 | char expected = '\n';
45 | if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
46 | expected = '\r';
47 | }
48 | Assert.assertEquals(expected, endLine);
49 | }
50 |
51 | @Test
52 | public void testWriteExactlyTheSame() throws IOException {
53 | File fileWithCR = File.createTempFile("test", "withCR.txt");
54 | FileWriter fw = new FileWriter(fileWithCR);
55 | String content = "test\r\n";
56 | fw.write(content);
57 | fw.close();
58 | char aux = writer.getEndLineChar(fileWithCR);
59 | FileWriter fw2 = new FileWriter(fileWithCR);
60 | writer.write("test\n", fw2, aux);
61 | fw2.flush();
62 | fw2.close();
63 | FileReader reader = new FileReader(fileWithCR);
64 | char[] buf = new char[content.length()];
65 | reader.read(buf);
66 | reader.close();
67 | Assert.assertEquals('\r', buf[4]);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/test/resources/add-mvn/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | "-Dversion=11.0 -Drelease=0"
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/resources/add-script/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | public class Foo {
2 | private String bar;
3 | }
4 |
--------------------------------------------------------------------------------
/src/test/resources/add-script/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | /Users/rpau/walkmodhub/walkmod-core/src/test/resources/scripts/myscript.groovy
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/add-template/jpa-id.groovy:
--------------------------------------------------------------------------------
1 | package ${query.resolve("root.package.name")};
2 |
3 | import javax.persistence.Id;import javax.persistence.GeneratedValue;
4 | import javax.persistence.GenerationType;
5 |
6 | public class ${query.resolve("type.name")}{
7 |
8 | @Id
9 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
10 | Integer id;
11 |
12 | @Override
13 | public boolean equals(Object o) {
14 | if (o instanceof ${query.resolve("type.name")}) {
15 | return id.equals(((${query.resolve("type.name")}) o).id);
16 | }
17 | return false;
18 | }
19 |
20 | @Override
21 | public int hashCode() {
22 | return id.hashCode();
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/src/test/resources/add-template/src/main/java/foo/Foo.java:
--------------------------------------------------------------------------------
1 | package foo;
2 |
3 | import javax.persistence.Id;
4 | import javax.persistence.GeneratedValue;
5 | import javax.persistence.GenerationType;
6 |
7 | public class Bar {
8 | @Id
9 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
10 | Integer id;
11 |
12 | @Override
13 | public boolean equals(Object o) {
14 | if (o instanceof Bar) {
15 | return id.equals(((Bar) o).id);
16 | }
17 | return false;
18 | }
19 |
20 | @Override
21 | public int hashCode() {
22 | return id.hashCode();
23 | }
24 | }
25 |
26 | public class Bar {
27 | public String bar;
28 | }
--------------------------------------------------------------------------------
/src/test/resources/add-template/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ["/Users/rpau/walkmodhub/walkmod-core/src/test/resources/add-template/jpa-id.groovy"]
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/different-folders/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 | org.walkmod.tests
7 | differentFolders
8 | 1.0
9 |
10 |
--------------------------------------------------------------------------------
/src/test/resources/different-folders/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | public class Foo {
2 |
3 | @Override
4 | public boolean equals(Object o) {
5 | return false;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/test/resources/different-folders/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module1/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | module1
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | 1.1.36
61 |
62 |
63 |
64 |
65 | default-tools.jar
66 |
67 |
68 | java.vendor
69 | Sun Microsystems Inc.
70 |
71 |
72 |
73 |
74 | com.sun
75 | tools
76 | 1.4.2
77 | system
78 | ${java.home}/../lib/tools.jar
79 |
80 |
81 |
82 |
83 | walkmod-core
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module1/src/main/java/Bar.java:
--------------------------------------------------------------------------------
1 | public class Bar {
2 | }
3 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module1/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module2/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | module2
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | default-tools.jar
60 |
61 |
62 | java.vendor
63 | Sun Microsystems Inc.
64 |
65 |
66 |
67 |
68 | com.sun
69 | tools
70 | 1.4.2
71 | system
72 | ${java.home}/../lib/tools.jar
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module2/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | public class Foo {
2 | }
3 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/module2/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | multimodule
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | 1.1.36
61 |
62 |
63 |
64 |
65 | default-tools.jar
66 |
67 |
68 | java.vendor
69 | Sun Microsystems Inc.
70 |
71 |
72 |
73 |
74 | com.sun
75 | tools
76 | 1.4.2
77 | system
78 | ${java.home}/../lib/tools.jar
79 |
80 |
81 |
82 |
83 |
84 | pom
85 |
86 |
--------------------------------------------------------------------------------
/src/test/resources/multimodule/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | module1
5 | module2
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/multimodulewithoutconfig/module1/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | module1
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | 1.1.36
61 |
62 |
63 |
64 |
65 | default-tools.jar
66 |
67 |
68 | java.vendor
69 | Sun Microsystems Inc.
70 |
71 |
72 |
73 |
74 | com.sun
75 | tools
76 | 1.4.2
77 | system
78 | ${java.home}/../lib/tools.jar
79 |
80 |
81 |
82 |
83 | walkmod-core
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/test/resources/multimodulewithoutconfig/module1/src/main/java/Bar.java:
--------------------------------------------------------------------------------
1 | public class Bar { }
2 |
--------------------------------------------------------------------------------
/src/test/resources/multimodulewithoutconfig/module2/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | module2
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | default-tools.jar
60 |
61 |
62 | java.vendor
63 | Sun Microsystems Inc.
64 |
65 |
66 |
67 |
68 | com.sun
69 | tools
70 | 1.4.2
71 | system
72 | ${java.home}/../lib/tools.jar
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/src/test/resources/multimodulewithoutconfig/module2/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | public class Foo { }
2 |
--------------------------------------------------------------------------------
/src/test/resources/multimodulewithoutconfig/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | multimodule
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | 1.1.36
61 |
62 |
63 |
64 |
65 | default-tools.jar
66 |
67 |
68 | java.vendor
69 | Sun Microsystems Inc.
70 |
71 |
72 |
73 |
74 | com.sun
75 | tools
76 | 1.4.2
77 | system
78 | ${java.home}/../lib/tools.jar
79 |
80 |
81 |
82 |
83 |
84 | module1
85 | module2
86 |
87 | pom
88 |
89 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/myscript.groovy:
--------------------------------------------------------------------------------
1 | import org.walkmod.javalang.ast.body.ModifierSet;
2 | import java.lang.reflect.Modifier;
3 | import org.walkmod.javalang.ast.body.FieldDeclaration;
4 |
5 | for(type in node.types){
6 | def fields = type.members.findAll({it instanceof FieldDeclaration});
7 | for (field in fields){
8 | int modifiers = ModifierSet.addModifier(field.modifiers, Modifier.PRIVATE);
9 | modifiers = ModifierSet.removeModifier(modifiers, Modifier.PROTECTED);
10 | modifiers = ModifierSet.removeModifier(modifiers, Modifier.PUBLIC);
11 | field.setModifiers(modifiers);
12 | }
13 | }
--------------------------------------------------------------------------------
/src/test/resources/scripts/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | public class Foo {
2 | private String bar;
3 | }
4 |
--------------------------------------------------------------------------------
/src/test/resources/scripts/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | groovy
5 | myscript.groovy
6 |
7 |
--------------------------------------------------------------------------------
/src/test/resources/simple/src/main/java/Foo.java:
--------------------------------------------------------------------------------
1 | import java.util.List;
2 |
3 | public class Foo{
4 |
5 | }
--------------------------------------------------------------------------------
/src/test/resources/simple/walkmod.yml:
--------------------------------------------------------------------------------
1 | transformations:
2 | - type: imports-cleaner
--------------------------------------------------------------------------------
/src/test/resources/templates/jpa-id.groovy:
--------------------------------------------------------------------------------
1 | package ${query.resolve("root.package.name")};
2 |
3 | import javax.persistence.Id;import javax.persistence.GeneratedValue;
4 | import javax.persistence.GenerationType;
5 |
6 | public class ${query.resolve("type.name")}{
7 |
8 | @Id
9 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
10 | Integer id;
11 |
12 | @Override
13 | public boolean equals(Object o) {
14 | if (o instanceof ${query.resolve("type.name")}) {
15 | return id.equals(((${query.resolve("type.name")}) o).id);
16 | }
17 | return false;
18 | }
19 |
20 | @Override
21 | public int hashCode() {
22 | return id.hashCode();
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/src/test/resources/testFiles/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | myorg
5 | testproject
6 | 1.0
7 |
8 |
9 | GNU General Public License (GPL v.3)
10 | http://www.gnu.org/licenses/gpl.txt
11 |
12 |
13 |
14 | 2.1.6
15 | UTF-8
16 | UTF-8
17 | UTF-8
18 |
19 |
20 |
21 |
22 | org.apache.maven.plugins
23 | maven-compiler-plugin
24 | 2.3.2
25 |
26 | 1.6
27 | 1.6
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-javadoc-plugin
33 |
34 |
35 | attach-javadocs
36 |
37 | jar
38 |
39 |
40 |
41 |
42 |
43 | org.apache.maven.plugins
44 | maven-source-plugin
45 |
46 |
47 | attach-sources
48 |
49 | jar
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | 1.1.36
61 |
62 |
63 |
64 |
65 | default-tools.jar
66 |
67 |
68 | java.vendor
69 | Sun Microsystems Inc.
70 |
71 |
72 |
73 |
74 | com.sun
75 | tools
76 | 1.4.2
77 | system
78 | ${java.home}/../lib/tools.jar
79 |
80 |
81 |
82 |
83 | walkmod-core
84 |
85 |
86 |
--------------------------------------------------------------------------------
/src/test/resources/testFiles/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/test/resources/yaml/basic.yml:
--------------------------------------------------------------------------------
1 | transformations: [
2 | {
3 | type: "walkmod:commons:method-refactor",
4 | params: {
5 | refactoringConfigFile: "src/conf/refactoring-methods.json"
6 | }
7 | },
8 | {
9 | type: "walkmod:commons:class-refactor",
10 | params: {
11 | refactoringConfigFile: "src/conf/refactoring-classes.json"
12 | }
13 | }
14 | ]
--------------------------------------------------------------------------------
/src/test/resources/yaml/chains.yml:
--------------------------------------------------------------------------------
1 | chains: [
2 | {
3 | name: "main-chain",
4 | reader: {
5 | path: "src"
6 | },
7 | transformations: [
8 | {
9 | type: "walkmod:commons:method-refactor",
10 | params: {
11 | refactoringConfigFile: "src/conf/refactoring-methods.json"
12 | }
13 | },
14 | {
15 | type: "walkmod:commons:class-refactor",
16 | params: {
17 | refactoringConfigFile: "src/conf/refactoring-classes.json"
18 | }
19 | }
20 | ],
21 | writer:{
22 | path: "src"
23 | }
24 | },
25 | {
26 | name: "main-chain-2",
27 | transformations: [
28 | {
29 | type: "walkmod:commons:method-refactor",
30 | params: {
31 | refactoringConfigFile: "src/conf/refactoring-methods.json"
32 | }
33 | },
34 | {
35 | type: "walkmod:commons:class-refactor",
36 | params: {
37 | refactoringConfigFile: "src/conf/refactoring-classes.json"
38 | }
39 | }
40 | ]
41 | }
42 | ]
--------------------------------------------------------------------------------
/src/test/resources/yaml/walkmod.yml:
--------------------------------------------------------------------------------
1 | plugins:
2 | - org.walkmod:walkmod-maven-plugin:[1.0, 2.0)
3 | - org.walkmod:walkmod-refactor-plugin:[2.0, 3.0)
4 |
5 | conf-providers:
6 | - type: walkmod:commons:maven
7 |
8 | chains:
9 | - name: main-chain
10 | transformations:
11 | - type: walkmod:commons:method-refactor
12 | params:
13 | refactoringConfigFile: src/conf/refactoring-methods.json
14 |
15 | - type: walkmod:commons:class-refactor
16 | params:
17 | refactoringConfigFile: src/conf/refactoring-classes.json
--------------------------------------------------------------------------------
/walkmod.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | src/main/license-header.txt
12 | reformat
13 |
14 |
15 |
16 |
17 | eclipse-formatter.xml
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------