maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MSHARED-763) Include a dependency change detection.
Date Thu, 11 Oct 2018 01:39:00 GMT

    [ https://issues.apache.org/jira/browse/MSHARED-763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16645827#comment-16645827
] 

ASF GitHub Bot commented on MSHARED-763:
----------------------------------------

olamy commented on a change in pull request #1: [MSHARED-763] - Include a dependency change
detection.
URL: https://github.com/apache/maven-shared-incremental/pull/1#discussion_r224290901
 
 

 ##########
 File path: src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java
 ##########
 @@ -359,6 +378,143 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
         }
 
     }
+    /**
+     * Detect whether the dependencies has changed since the last build.
+     *
+     * @param incrementalBuildHelperRequest
+     * @return <code>true</code> if the set of dependencies got changed since
the last build.
+     * @throws MojoExecutionException
+     */
+    public boolean dependencyTreeChanged( IncrementalBuildHelperRequest incrementalBuildHelperRequest
)
+            throws MojoExecutionException
+    {
+        File mojoConfigBase = getMojoStatusDirectory();
+        File mojoConfigFile = new File ( mojoConfigBase, DEPENDENCY_INFO_FILENAME );
+
+        classpathElements.clear();
+        dependencyInfo.clear();
+
+        final List<String> classpathElementsNew = incrementalBuildHelperRequest.getClasspathElements();
+
+        for ( String  classPathElement : classpathElementsNew )
+        {
+            File artifactPath = new File ( classPathElement );
+            if ( artifactPath.isFile() )
+            {
+                dependencyInfo.put( artifactPath, artifactPath.lastModified() );
+                classpathElements.add( artifactPath );
+            }
+        }
+        if ( dependencyInfo == null )
+        {
+            return false;
+        }
+        if ( !mojoConfigFile.exists() )
+        {
+            //no file, assume rebuild
+            return true;
+        }
+
+        Map<File, Long> origDependencyInfo;
+        List<File> origClasspathElements;
+        try
+        {
+            ObjectInputStream ois = new ObjectInputStream ( new FileInputStream( mojoConfigFile
) );
+            origClasspathElements = ( List<File> ) ois.readObject();
+            origDependencyInfo = ( Map<File, Long> ) ois.readObject();
+            ois.close();
+        }
+        catch ( FileNotFoundException e )
+        {
+            //no file, assume rebuild
+            return true;
+        }
+        catch ( IOException e )
+        {
+            //assume rebuild
+            return true;
+        }
+        catch ( ClassNotFoundException e )
+        {
 
 Review comment:
   java7 so please catch with multiple exceptions 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Include a dependency change detection.
> --------------------------------------
>
>                 Key: MSHARED-763
>                 URL: https://issues.apache.org/jira/browse/MSHARED-763
>             Project: Maven Shared Components
>          Issue Type: Improvement
>          Components: maven-shared-incremental
>            Reporter: Liwae Lamaa
>            Priority: Major
>
> Currently, maven incremental compilation does not detect dependency change.
> Sample scenario:
>  * Project A depends on Project B.
>  * Project B is recompiled.
>  * Project A should detect this change and recompile. (which is not the case currently)
>  * If B recompilation includes changing an interface, we expect A to recompile and fail
accordingly. 
> A fix was already performed on *maven-compiler-plugin*, but it was never merged. 
> https://issues.apache.org/jira/browse/MCOMPILER-278 
> After recent discussion with [~rfscholte], he decided that the fix should rather be in
*maven-shared-incremental.* I have performed the implementation for the fix in maven-shared-incremental,
and I will be forking the project for that.
> PS: The change include minor change in the *maven-compiler-plugin* for it to take effect.
Jira issue in maven-compiler-plugin: https://issues.apache.org/jira/browse/MCOMPILER-363



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message